Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Last active April 23, 2020 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NyaGarcia/425b9cc1e5f0a6ecb4da9b1823396bc3 to your computer and use it in GitHub Desktop.
Save NyaGarcia/425b9cc1e5f0a6ecb4da9b1823396bc3 to your computer and use it in GitHub Desktop.
Creating an Observable with from()
// 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