Last active
April 23, 2020 18:22
-
-
Save NyaGarcia/425b9cc1e5f0a6ecb4da9b1823396bc3 to your computer and use it in GitHub Desktop.
Creating an Observable with from()
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
// Creating an Observable from an array of strings | |
const fruit$ = from(["Strawberry", "Cherry", "Blackberry"]); | |
// Creating an Observable from a Map object | |
const pokemon$ = from( | |
new Map([ | |
["Squirtle", "Water"], | |
["Charmander", "Fire"], | |
["Bulbasur", "Grass"] | |
]) | |
); | |
// Creating an Observable from a promise | |
const promise$ = from(Promise.resolve("I promise to start learning RxJS")); | |
// Creating an Observable from a nodeList | |
const node$ = from(document.querySelectorAll("p")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment