January 2019
Beginner
210 pages
4h 47m
English
We can create an observable given an existing array using the from function:
import { from } from "rxjs";const observable = from([10, 20, 30]);const subscription = observable.subscribe( (value) => console.log(value), (error: any) => console.log(error), () => console.log("Done!"));subscription.unsubscribe();
The preceding code snippet declares an observable with three values using the from function. The code snippet also showcases how we can subscribe once more.
The following marble diagram represents the preceding example in a visual manner. The generated observable has three values (10, 20, and 30) and 30 is the last element in the observable:
We can alternatively use the interval function to generate an ...
Read now
Unlock full access