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 { pausable, PausableObservable } from 'rxjs-pausable'; | |
| const source = interval(1000).pipe( | |
| map(x => `Hello ${x}!`), | |
| pauseable() | |
| ) as PausableObservable<string>; | |
| source.subscribe(console.log); | |
| setTimeout(() => source.pause(), 5000) |
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
| const source = of('World'); | |
| // with tap | |
| source.pipe( | |
| tap(x => console.log(x)) | |
| ).subscribe(x => { | |
| this.doSomething(x); | |
| }); | |
| // with map |
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
| export function log() { | |
| return function logFn() {}; | |
| } |
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
| export function log() { | |
| return function logFn<T>(source: Observable<T>) { | |
| const output = new Observable<T>(observer => {}); | |
| return output; | |
| }; | |
| } |
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
| export function log() { | |
| return function logFn<T>(source: Observable<T>) { | |
| const output = new Observable<T>(observer => { | |
| source.subscribe( | |
| val => console.log(val), | |
| err => console.error(err), | |
| () => console.log('%ccomplete', 'color: green') | |
| ); | |
| }); | |
| return output; |
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
| export function log() { | |
| return function logFn<T>(source: Observable<T>) { | |
| const output = new Observable<T>(observer => { | |
| source.subscribe( | |
| val => { | |
| console.log(val); | |
| observer.next(val); | |
| }, | |
| err => console.error(err), | |
| () => console.log('%ccomplete', 'color: green') |
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
| export function log() { | |
| return function logFn<T>(source: Observable<T>) { | |
| const output = new Observable<T>(observer => { | |
| source.subscribe( | |
| val => { | |
| console.log(val); | |
| observer.next(val); | |
| }, | |
| err => { | |
| console.error(err); |
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
| export function log() { | |
| return function logFn<T>(source: Observable<T>) { | |
| const output = new Observable<T>(observer => { | |
| const subscription = source.subscribe( | |
| val => { | |
| console.log(val); | |
| observer.next(val); | |
| }, | |
| err => { | |
| console.error(err); |
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 { log } from '/path/to/utils/operators'; | |
| const source = of(1, 2, 3, 4); | |
| source.pipe( | |
| log(), | |
| map(v => v ** 2), | |
| log(), | |
| filter(v => v > 5), | |
| log() |
OlderNewer