Reputation: 14012
So what is the difference between of
operator and Observable.of
and what is the recommended way to create an observable?
import { Observable } from 'rxjs/Observable';
const obs$ = Observable.of(3);
or
import { of as observableOf } from 'rxjs';
const obs$ = observableOf(3);
Upvotes: 3
Views: 5677
Reputation: 15196
The second way is the preferred way, and going forward (from rxjs v7) the only way. Currenly in v6 you can still use the first by including the rxjs-compat package, but writing new code, you should stick to the last method mentioned.
Upvotes: 6