Demo: iif
The iif can lazily create one of the two observables based on the given condition.
It's like a subset of defer where we can lazily create any desired observables.
//iif(condition , observableIfTrue , observableIfFalse);
let input = iif(() => (Math.random() > 0.5) ,
interval(500) , timer(1000, 1500));
//take first 5 outputs
let process = take(5);
let output = input.pipe(process).subscribe(v=>console.log(v))