Created
October 18, 2019 18:33
-
-
Save traviskaufman/05f921dd21f7ddbc04894567bd9e7cb4 to your computer and use it in GitHub Desktop.
Demystifying RxJS, Part I: of()
This file contains 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 of<T>(...values: T[]): Observable<T> { | |
return new Observable(obs => { | |
for (const value of values) { | |
obs.next(value); | |
} | |
obs.complete(); | |
}); | |
} | |
// Logs: | |
// of 1 | |
// of 2 | |
// of 3 | |
of(1, 2, 3).subscribe(x => console.log("of", x)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment