Skip to content

Commit

Permalink
fix: unsubscribe streamItems on deinit (#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
radko93 authored Aug 25, 2020
1 parent da78399 commit b1cde83
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/assets/javascripts/services/preferencesManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,25 @@ export class PreferencesManager extends ApplicationService {

private userPreferences!: SNUserPrefs
private loadingPrefs = false;
private unubscribeStreamItems?: () => void;

/** @override */
async onAppLaunch() {
super.onAppLaunch();
this.reloadSingleton();
this.streamPreferences();
}

deinit() {
this.unubscribeStreamItems && this.unubscribeStreamItems();
}

get webApplication() {
return this.application as WebApplication;
}

streamPreferences() {
this.application!.streamItems(
this.unubscribeStreamItems = this.application!.streamItems(
ContentType.UserPrefs,
() => {
this.reloadSingleton();
Expand Down

0 comments on commit b1cde83

Please sign in to comment.