Last active
September 2, 2018 22:16
-
-
Save Devcon4/00a857372bb0742904d4a3ff5d1cafee to your computer and use it in GitHub Desktop.
CreateObservable.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { of, BehaviorSubject } from 'rxjs'; | |
| import { take, map } from 'rxjs/operators'; | |
| // Create observable. | |
| const obs = of([1, 2, 3]); | |
| const sub1 = obs.subscribe(console.log); | |
| const sub2 = obs.pipe(take(1)).subscribe(console.log); | |
| const sub3 = obs.pipe(map(arr => arr[0])).subscribe(console.log); | |
| // output. | |
| // [ 1, 2, 3 ] | |
| // [ 1, 2, 3 ] | |
| // 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment