Example 1: Emitting a sequence of numbers
( StackBlitz | jsBin | jsFiddle )
// RxJS v6+import { of } from 'rxjs';//emits any number of provided values in sequenceconst source = of(1, 2, 3, 4, 5);//output: 1,2,3,4,5const subscribe = source.subscribe(val => console.log(val));
Example 2: Emitting an object, array, and function
( StackBlitz | jsBin | jsFiddle )
// RxJS v6+import { of } from 'rxjs';//emits values of any typeconst source = of({ name: 'Brian' }, [1, 2, 3], function hello() {return 'Hello';});//output: {name: 'Brian'}, [1,2,3], function hello() { return 'Hello' }const subscribe = source.subscribe(val => console.log(val));
βBattleship Gameβ
βBreakout Gameβ
βCar Racing Gameβ
βMine Sweeper Gameβ
βPlatform Jumper Gameβ
βSave Indicatorβ
βSwipe To Refreshβ
βTetris Gameβ
βType Aheadβ
βof π° - Official docs
βof - In Depth Dev Reference
βCreation operators: ofβ
π₯ π΅ - AndrΓ© Staltz
βBuild your own of operatorβ
π₯ - Kwinten Pisman
π Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/internal/observable/of.tsβ