import { Observable } from 'rxjs'; const array = [1, 2, 3]; const observable = Observable.from(array); observable.subscribe(val => console.log(val)); // Output: // 1 // 2 // 3
import { Observable } from 'rxjs'; const set = new Set(['a', 'b', 'c']); const observable = Observable.from(set); observable.subscribe(val => console.log(val)); // Output: // a // b // cIn this example, we create an observable from a `Set` object using the `Observable.from` function. We then subscribe to this observable, which logs each value emitted by the observable to the console. Package library: `rxjs` package.