Skip to content

Commit

Permalink
Update appconfigservice.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Dec 10, 2024
1 parent 434c2d3 commit aa41db2
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions apps/showcase/service/appconfigservice.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AppState } from '@/domain/appstate';
import { DOCUMENT, isPlatformBrowser } from '@angular/common';
import { computed, effect, inject, Injectable, PLATFORM_ID, signal } from '@angular/core';
import { AppState } from '@/domain/appstate';
@Injectable({
providedIn: 'root'
})
Expand All @@ -26,19 +26,16 @@ export class AppConfigService {
constructor() {
this.appState.set({ ...this.loadAppState() });

effect(
() => {
const state = this.appState();

if (!this.initialized || !state) {
this.initialized = true;
return;
}
this.saveAppState(state);
this.handleDarkModeTransition(state);
},
{ allowSignalWrites: true }
);
effect(() => {
const state = this.appState();

if (!this.initialized || !state) {
this.initialized = true;
return;
}
this.saveAppState(state);
this.handleDarkModeTransition(state);
});
}

private handleDarkModeTransition(state: AppState): void {
Expand Down

0 comments on commit aa41db2

Please sign in to comment.