Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rxjs dont emit until value is not null

Tags:

rxjs

I have an Observable (lets call it myob$) which emits values like this:

----- null ----- 1 ----------- 5 ---->

If i do:

myob$.subscribe(x => console.log(x))

the output is ----- null ----- 1 ----------- 5 ---->

Can I add a pipe so it does not emit until the value from myob$ is not null?

something like:

myob$.pipe(x => ignoreEverytingUntilXIsNotNull).subscribe(x => console.log(x))

So that the output is --------------- 1 ----------- 5 ---->

Thanks in advance

like image 526
danday74 Avatar asked Aug 10 '18 00:08

danday74


1 Answers

bah I'm thick, I think you just need to do:

myob$.filter(x => !!x).subscribe(x => console.log(x))

assuming no 0's are being emitted :)

like image 71
danday74 Avatar answered Oct 23 '22 03:10

danday74