Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rx.Observable.just is not a function in JSBIN & RxJS 5

Tags:

rxjs5

jsbin

In JsBin, I got error "Rx.Observable.just is not a function" in Firefox & Chrome. JsBin example : http://jsbin.com/vunuta/edit?html,js,console

HTML :

script src="https://npmcdn.com/@reactivex/[email protected]/dist/global/Rx.umd.js">

Typescript :

Rx.Observable.from ([1,2,3]).subscribe(x => console.log(x)); // Work
Rx.Observable.just (99).subscribe(x => console.log(x)); // Fail
Rx.Observable.return (99).subscribe(x => console.log(x)); // Fail

Tx

like image 677
Philippe sillon Avatar asked Aug 26 '16 14:08

Philippe sillon


2 Answers

Rx.Observable.just() is no longer provided in v5. Use Rx.Observable.of(). https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md

like image 180
Harshal Patil Avatar answered Oct 17 '22 22:10

Harshal Patil


Update for rxjs v6

Yes, use of instead of just. The import and usage of of changed between rxjs v5 and rxjs v6.

For rxjs v6, use of as in the following example code:

import { of } from "rxjs";

let source$ = fromPromise(getPostById(1)).pipe(
  flatMap(post => {
    return hydrateAuthor(post);
  }),
  catchError(error => of(`Caught error: ${error}`))
);
like image 25
arcseldon Avatar answered Oct 17 '22 23:10

arcseldon