Reputation: 2047
I was doing some code cleanup for my ngrx project at work and found some RXJS code that was not following our usual practices. I was wondering if it was safe to replace it with code that does match our usual practices.
This is the code that does not match our normal practices:
stream$.takeUntil(Observable.timer(0)).subscribe();
I want to know if the code above is equivalent to the following code:
stream$.take(1).subscribe();
From the timer documentation and the take documentation that I've read, these two lines of code appear to be equivalent. Is that the correct conclusion?
Upvotes: 1
Views: 225
Reputation: 20033
I want to know if the code above is equivalent to the following code:
No, it is not:
const stream$ = Observable.of(1, 2, 3);
Will give
stream$.takeUntil(Observable.timer(0)) // 1, 2, 3
stream$.take(1) // 1
Upvotes: 3