What does the word "of" mean in Rxjs?

Asked

Viewed 100 times

1

What does the word "of" mean in Rxjs ? Example:

const source = of('World').pipe(
  map(x => `Hello ${x}!`)
);
  • 4

    Converts the arguments into an observable sequence. From the documentation. https://rxjs-dev.firebasepp.com/api/index/function/of

  • 1

    You can have a look at the documentation: https://www.learnrxjs.io/operators/creation/of.html

  • 1

    If you look in the google search for: rxjs of there will be a good supply of documentation.

1 answer

2


As @LINQ commented, the creation operator of converts the arguments into an observable sequence:

// RxJS v6+
import { of } from 'rxjs';
//emits any number of provided values in sequence
const source = of(1, 2, 3, 4, 5);
//output: 1,2,3,4,5
const subscribe = source.subscribe(val => console.log(val));

Console output:

1
2
3
4
5

Link to documentation: https://rxjs-dev.firebaseapp.com/api/index/function/of

The link below shows a table to give an idea of which creation operator should be used according to the scenario:

https://xgrommx.github.io/rx-book/content/which_operator_do_i_use/creation_operators.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.