chrisl-921fb74d
chrisl-921fb74d

Reputation: 23120

Angular2 - rxjs observe vs dispose?

What's the difference between unsubscribe and disposing ?

e.g.

// app-service.ts
{Http} from @angular/core;

export class appService {
   constructor(private http : Http, fooService : FooService) {}
   getAll() {
       // do this
       this.sub = this.fooService.subscribe(
           () => {}, 
           error => throw new Error(error), 
           () => {}
       )
   }

   ngOnDestroy() {
      this.sub.dispose();
   }
}

Upvotes: 1

Views: 251

Answers (1)

eko
eko

Reputation: 40647

It is a rxjs4 - rxjs5 difference;

In rxjs4 there were Disposables that you dispose(), now they are Subscriptions that you unsubscribe()

Source: https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md

Upvotes: 6

Related Questions