Reputation: 1988
In a template, I set an async pipe for a Observable with.
*ngFor="let checkIn of checkIns | async"
In the component, this.checkIns = this.service.getCheckIns()
.
In the service, I got:
getCheckIns(): Observable<any> {
return new Observable((observer) => {
observer.next(...)
}
}
I notice if I swap out new Observable()
with Observable.create()
, there's no difference:
getCheckIns(): Observable<any> {
return Observable.create((observer) => {
observer.next(...)
}
}
Upvotes: 1
Views: 73
Reputation: 96949
This is correct, these two are synonymous.
See source code: https://github.com/ReactiveX/rxjs/blob/master/src/Observable.ts#L56
The static method Observable.create(...)
just calls new Observable(...)
under the hood.
Upvotes: 2