What is the `return of ()` syntax

I am considering this piece of code:

enter image description here

This is typescript. On the first line there is:

... return of (true); 

What is the syntax?

+5
source share
3 answers

Most of the short function names in this snippet are RxJS statements .

Instead:

  • Observable.of()
  • Observable.from()
  • Observable.mergeMap()

You have:

  • of()
  • from()
  • mergeMap()

Look at the top of the snippet, you should see the import for these RxJS statements.

Please note that this is NOT a common practice (I think this makes the code more difficult to read).

+9
source

Its function is probably called of , in which true is passed. Spaces are not related to parentheses.

+1
source

of not a TypeScript keyword, there must be a function somewhere called of

  function of<T>(value: T) { // ... } 
+1
source

Source: https://habr.com/ru/post/1264305/


All Articles