简体   繁体   中英

Will takeUntil() work with Observable<void>?

The documentation says that takeUntil continues to emit values until the passed observable emits a value . It doesn't say until subscribe is called.

I'm wondering if the following is safe to do?

const x = new Subject<void>();

async.pipe(takeUntil(x)).subscribe(()=>.....);

x.next(); // <-- no value

The alternative would be to emit some kind of value in x.next(true) .

Yes calling x.next() is safe. By inspecting the source code it can be seen that takeUntil does not use the value emitted from Observable x and simply calls complete() on the source Observable.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM