Public
Authored by Melroy van den Berg

Avoid memory leaks by unsubscribing in Angular

Using takeWhile rxjs operators in rxjs / Angular like it should be, to avoiding memory leaks.

Using the same boolean in the component for both the BehaviorSubject as well as HttpClient obvervables.

Defining my BehaviorSubject is done like this (in another service):

  private setPageSource = new BehaviorSubject<PageEventData>(new PageEventData())
  // Observable
  setPage$ = this.setPageSource.asObservable()
Edited
myservice.ts 2.36 KB
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment