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 suspend<T>(): OperatorFunction<T, SuspendedValue<T>> { | |
| return (source: Observable<T>) => | |
| source.pipe( | |
| map((next) => ({ | |
| value: next, | |
| isLoading: false, | |
| error: null | |
| })), | |
| catchError((error) => of({ error, isLoading: false, value: null })), | |
| startWith({ isLoading: true, value: null, error: null }) |
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
| class Car { | |
| constructor(opts) { | |
| this.model = opts.model; | |
| this.year = opts.year; | |
| this.miles = opts.miles; | |
| } | |
| toString() { | |
| return this.model + ' has driven ' + this.miles + ' miles'; | |
| } | |
| } |
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 selectEntries(options) { | |
| options = options || {}; | |
| var start = options.start || 0; | |
| var end = options.end || -1; | |
| var step = options.step || 1; | |
| // function implementation | |
| } | |
| selectEntries({ start: 3, end: 20, step: 2 }); |
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 takeChance(probability) { | |
| probability = probability / 100; | |
| return !!probability && Math.random() <= probability; | |
| } |