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?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.