fix: unsubscribe streamItems on deinit (#453)

This commit is contained in:
Radek Czemerys
2020-08-25 17:36:01 +02:00
committed by GitHub
parent da78399567
commit b1cde8308f

View File

@@ -13,6 +13,7 @@ export class PreferencesManager extends ApplicationService {
private userPreferences!: SNUserPrefs private userPreferences!: SNUserPrefs
private loadingPrefs = false; private loadingPrefs = false;
private unubscribeStreamItems?: () => void;
/** @override */ /** @override */
async onAppLaunch() { async onAppLaunch() {
@@ -20,13 +21,17 @@ export class PreferencesManager extends ApplicationService {
this.reloadSingleton(); this.reloadSingleton();
this.streamPreferences(); this.streamPreferences();
} }
deinit() {
this.unubscribeStreamItems && this.unubscribeStreamItems();
}
get webApplication() { get webApplication() {
return this.application as WebApplication; return this.application as WebApplication;
} }
streamPreferences() { streamPreferences() {
this.application!.streamItems( this.unubscribeStreamItems = this.application!.streamItems(
ContentType.UserPrefs, ContentType.UserPrefs,
() => { () => {
this.reloadSingleton(); this.reloadSingleton();