Rose Nettoyeur
Rose Nettoyeur

Reputation: 919

How to get "Observable.of([]);" to work?

What is the correct expression and import for Observable.of([]);.

import { of } from 'rxjs'; does not work for me.

Upvotes: 8

Views: 9353

Answers (2)

sushil suthar
sushil suthar

Reputation: 679

No need to use Observable.of(T) Instead you can use the below syntax in the rxjs 6.3.3

return new Observable<AppUser>();

Upvotes: -1

martin
martin

Reputation: 96949

Since RxJS 6 you should import all "creation" observables directly from 'rxjs' (assuming you have path maps set when bundling your app).

More detailed explanation: https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md#import-paths

import { of } from 'rxjs';

of(1).subscribe(console.log);

See demo: https://stackblitz.com/edit/typescript-e3lxkb?file=index.ts

Upvotes: 19

Related Questions