21

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/rxjs@5.0.0-beta.7/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

Philippe sillon
  • 1,572
  • 2
  • 14
  • 20

2 Answers2

37

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

Harshal Patil
  • 17,838
  • 14
  • 60
  • 126
5

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}`))
);
arcseldon
  • 35,523
  • 17
  • 121
  • 125