In Rxjs ,I know the subscribe method has three three types of values an Observable Execution:next,error,complete.It's easy to write a arrow function in subscribe() method,but I met the subscribe({}) method somewhere .So I don't know what it means.for example:
var observable = Rx.Observable.create(function (observer) { observer.next(1); observer.next(2); observer.next(3); setTimeout(() => { observer.next(4); observer.complete(); }, 1000); }); console.log('just before subscribe'); observable.subscribe({ next: x => console.log('got value ' + x), error: err => console.error('something wrong occurred: ' + err), complete: () => console.log('done'), }); console.log('just after subscribe'); in this example it use the observable.subscribe({}),and different expression example like the follow:
getHeroes() { this.heroService.getHeroes() .subscribe( heroes => this.heroes = heroes, error => this.errorMessage = <any>error); }