Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
630 views
in Technique[技术] by (71.8m points)

angular - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...