Stream
Class Signature
class Stream {
constructor(observable: Observable<any>){
}
}Explicit Usage Example
import {timer} from 'rxjs';
import {tap} from 'rxjs/operators';
import {Stream} from '@activejs/core';
// create a cold Observable that emits at a 1-second interval.
// RxJS timer emits incremental numbers starting from 0
const randomNumberLogger$ = timer(0, 1000).pipe(
tap(count => console.log(count))
);
// create a Stream using the randomNumberLogger$
const randomNumberStream = new Stream(randomNumberLogger$);
// each passing second we'll see a number logged in console
// 0, 1, 2, 3, and so on
// restart the timer
randomNumberStream.resubscribe();
// and the timer will start again
// again we'll see 0, 1, 2, 3, and so on
// you can also stop the stream similar to a simple Subscription
randomNumberStream.unsubscribe();Implicit Usage Example
Last updated
Was this helpful?