You have already learned how to create an observable from a sequence using the from() method, but there is a way to create an observable from an arbitrary sequence of arguments. We can do this using the of() method.
This method creates an observable that emits each argument passed to it.
The of() method has the following signature:
The three dots before args illustrate an arbitrary number of arguments.
- ...args: This refers to any number of objects
The following code shows an implementation of the of() method:
Rx.Observable .of(0,1,2) .subscribe((i)=>console.log(i));
If you run this code, you will see the following output:
0 1 2
Now let's see what happens ...