Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Created April 23, 2020 14:55
Show Gist options
  • Save NyaGarcia/34937b07f5014e2e9890acddde44825d to your computer and use it in GitHub Desktop.
Save NyaGarcia/34937b07f5014e2e9890acddde44825d to your computer and use it in GitHub Desktop.
Creating several Observables with of()
import { of } from "rxjs";
// Creating an Observable of numbers
const number$ = of(1, 2, 3, 4, 5);
// Creating an Observable of strings
const pokemon$ = of("Squirtle", "Charmander", "Bulbasur");
// Creating an Observable of arrays
const fruit$ = of(["Strawberry", "Cherry"], ["Lemon", "Orange"]);
// Creating an Observable of objects
const iceCream$ = of(
{ size: "Large", toppings: ["Oreos", "Chocolate syrup"] },
{ size: "small", toppings: ["Strawberries"] }
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment