Created
April 23, 2020 14:55
-
-
Save NyaGarcia/34937b07f5014e2e9890acddde44825d to your computer and use it in GitHub Desktop.
Creating several Observables with of()
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 { 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