In Rxjs, there is the pipe takeUntil but there isn't a pipe wait Until, that makes the current observable waiting for a seconde Observable to emit.
My Final Goal is to make many Observable still waiting until my Observable init$ emits just one value, to continue their execution. So that my Observable init$ has to been executed once and before that my other observable have to wait until inits emits any value different from null.
In this simple exemple, I want to add a pipe to pipedSource doing wait Until init$ , So the source has to wait until init$ emits to emit its value.
import { interval, timer, Subject, combineLatest } from 'rxjs';
import { takeUntil, skipWhile, skipUntil, concatMap, map, take } from 'rxjs/operators';
import { BehaviorSubject } from 'rxjs';
const init$ = new BehaviorSubject(null);
const source = new BehaviorSubject(null);
const pipedSource = source
.pipe(
skipWhile((res)=> res === null)
//wait until init$ emits a non null value
)
//first subscription to source
pipedSource.subscribe(val => console.log(val));
source.next({profile:"me"});
//init emits once
setTimeout(()=>{
init$.next(1);
},2000);
// a second subscription to source
setTimeout(()=>{
pipedSource.subscribe(val => console.log(val));
},3000);
wanted result:
//after 2s of waiting
//first subscription returns "profile"
//after 3s
//second subscription returns "profile"