Created
September 5, 2021 08:59
-
-
Save banujan6/307dfe06262ab5fa42ccbc98a7fa5916 to your computer and use it in GitHub Desktop.
medium-rxjs-operators-pipeable
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'; | |
import { first } from 'rxjs/operators'; | |
// Create a Observable which emits 2 values | |
const observable = new Observable(subscriber => { | |
subscriber.next('First Message'); | |
subscriber.next('Second Message'); | |
}); | |
// "first()" is a pipeable operator that only returns the observable with the first value. | |
observable | |
.pipe(first()) | |
.subscribe(data => console.log(data)); | |
// CONSOLE OUTPUT ------------------ | |
// > First Message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment