C
C
coderlex2017-07-16 20:39:44
Angular
coderlex, 2017-07-16 20:39:44

Is unsubscribe() needed after takeUntil().subscribe()?

Do I need to save subscription for later "unsubscribe" in ngOnDestroy (see code below)? Or will all cleanup work be done automatically after the predicate in takeUntil is executed?

public ngOnInit() {
  this.actions$
    .ofType(SIGNUP_FAILURE)
    .takeUntil(this.destroyed$)
    .do((action: Action) => {
      ...
    })
    .subscribe();
}

public ngOnDestroy() {
  this.destroyed$.next(true);
  this.destroyed$.complete();
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2017-07-16
@sHinE

Somewhere on SO, such a method for clearing memory was recommended, as far as I understood - it was not necessary to do unsubscribe() there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question