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
| function* simpleGenerator() { | |
| yield 1; | |
| yield 4; | |
| } | |
| for (let value of simpleGenerator()) { | |
| console.log(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
| function* simpleGenerator() { | |
| yield 1; | |
| yield 4; | |
| } | |
| let iterator = simpleGenerator(); | |
| let iteratorResult = iterator.next(); | |
| console.log(iteratorResult); // {value: 1, done: false} |
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
| function* simpleGenerator() { | |
| yield 1; | |
| yield 4; | |
| } | |
| let iterator = simpleGenerator(); | |
| let iteratorResult; | |
| do { | |
| iteratorResult = iterator.next(); |
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 button = document.getElementById('btnClick'); | |
| button.addEventListener('click', onButtonClick); | |
| function onButtonClick(event: MouseEvent) { | |
| console.log(event.target); | |
| } |
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, Observer } from 'rxjs'; | |
| let words = ['coding blast', 'coding', 'blast']; | |
| let source = Observable.from(words); | |
| class SimpleObserver implements Observer<string> { | |
| next(value: string) { | |
| 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
| let observer = new SimpleObserver(); | |
| source.subscribe(observer); | |
| let observer2 = new SimpleObserver(); | |
| source.subscribe(observer2); |
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
| interface ISimpleObserver<T> { | |
| next: (value: T) => void; | |
| error: (err: any) => void; | |
| complete: () => void; | |
| } |
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.fromEvent(document, 'mousemove'); | |
| source.subscribe(next, error, complete); | |
| 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.from(words); | |
| function next(value: string) { | |
| 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'; | |
| interface ISimpleObserver<T> { | |
| next: (value: T) => void; | |
| error: (err: any) => void; | |
| complete: () => void; | |
| } | |
| let words = ['coding blast', 'coding', 'blast']; |