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 { Observable } from 'rxjs'; | |
| let numbers = [1, 2, 3]; | |
| let source = Observable | |
| .from(numbers) | |
| .map(n => n * 2) | |
| .filter(n => n > 5); | |
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 { Observable } from 'rxjs'; | |
| let words = ['coding blast', 'badword', 'coding', 'blast']; | |
| let source = Observable.create(observer =>{ | |
| for (let word of words) { | |
| if (word === 'badword') { | |
| observer.error('Bad word!'); | |
| } | |
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
| source.subscribe(next); | |
| function next(value: any) { | |
| console.log('next: ', value); | |
| } |
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 {Observable} from 'rxjs'; | |
| let words = ['coding blast', 'coding', 'blast']; | |
| let source = Observable.create(observer => { | |
| for (let word of words) { | |
| observer.next(word); | |
| } | |
| observer.complete(); | |
| }); |
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 {Observable} from 'rxjs'; | |
| let words = ['coding blast', 'badword', 'coding', 'blast']; | |
| let source = Observable.create(observer => { | |
| for (let word of words) { | |
| if (word === 'badword') { | |
| observer.error('Bad word!'); | |
| } |
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 {Observable} from 'rxjs'; | |
| let words = ['coding blast', 'badword', 'coding', 'blast']; | |
| let source = Observable.create(observer => { | |
| for (let word of words) { | |
| if (word === 'badword') { | |
| observer.error('Bad word!'); | |
| } |
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
| let source = Observable.create(observer => { | |
| for (let word of words) { | |
| if (word === 'badword') { | |
| throw new Error('Bad word!'); | |
| } | |
| observer.next(word); | |
| } | |
| observer.complete(); |
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 {Observable} from 'rxjs'; | |
| let source = Observable | |
| .of('coding blast', 'badword', 'coding', 'blast') | |
| .map(w => w + ' RxJS'); | |
| console.log('before subscribe'); | |
| source.subscribe(function next(value) { | |
| console.log('Subscriber - next: ', value); |
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 {Observable} from 'rxjs'; | |
| let source = Observable | |
| .of('coding blast', 'badword', 'coding', 'blast') | |
| .map(w => w + ' RxJS'); | |
| console.log('before subscribe'); | |
| source.subscribe(function next(value) { | |
| console.log('Subscriber - next: ', value); |
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 {Observable} from 'rxjs'; | |
| Observable | |
| .fromEvent(document, 'mousemove') | |
| .forEach(function next(value) { | |
| console.log('next: ', value); | |
| }); |