Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {Subject} from "rxjs/Subject";
- import {combineLatest} from "rxjs/observable/combineLatest";
- import {Observable} from "rxjs/Observable";
- const subj1: Subject<string> = new Subject<string>();
- const subj2: Subject<number> = new Subject<number>();
- const combined: Observable<any> = combineLatest(subj1, subj2);
- combined.subscribe((arg) => {
- console.log('combined');
- console.log(arg);
- }, () => {
- console.log('error')
- });
- setTimeout(() => {
- console.log('first timer');
- subj1.next('hello');
- }, 1000);
- setTimeout(() => {
- console.log('second timer');
- subj2.next(1);
- }, 2000);
- setTimeout(() => {
- console.log('3rd timer');
- subj1.next('world');
- }, 3000);
- setTimeout(() => {
- console.log('4th timer');
- subj1.error(new Error('stam'));
- }, 3000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement