RxJS of() Creation OperatorRxJS of() operator is a creation operator used to convert the arguments to an observable sequence. It emits a variable amount of values in a sequence and then returns a complete notification. In other words, we can say that the RxJS of() operator takes the arguments passed and convert them to observable. In this operator, each argument becomes the next notification. Unlike the from() operator, it does not do any flattening and emits each argument in whole as a separate next notification. Syntax:Following is the syntax of the RxJS of() creation operator: Or Or Parameter Explanation
Return valueThe RxJS of() operator returns an observable with values from the source observable. It emits the arguments described above and then completes. Let us see some examples of the RxJS of() operator to understand it clearly. Example 1 (Emitting a sequence of numbers)Output: After executing the above example, you will see the following result: Example 2 (Emitting an array)Output: After executing the above example, you will see the following result: Example 3 (Emitting an object and function)Output: After executing the above example, you will see the following result:
Next TopicRxJS Operators
|