MCPcopy Index your code
hub / github.com/angular/components / getAppState

Function getAppState

src/dev-app/dev-app/dev-app-state.ts:28–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26
27/** Gets the current appearance state of the dev app. */
28export function getAppState(): DevAppState {
29 let value: DevAppState | null = null;
30
31 // Needs a try/catch since some browsers throw an error when accessing in incognito.
32 try {
33 const storageValue = localStorage.getItem(KEY);
34
35 if (storageValue) {
36 value = JSON.parse(storageValue);
37 }
38 } catch {}
39
40 if (!value) {
41 value = {
42 density: 0,
43 animations: true,
44 zoneless: false,
45 darkTheme: false,
46 systemTheme: true,
47 rippleDisabled: false,
48 strongFocusEnabled: false,
49 m3Enabled: true,
50 direction: 'ltr',
51 colorApiBackCompat: true,
52 };
53
54 saveToStorage(value);
55 }
56
57 return value;
58}
59
60/** Saves the state of the dev app apperance in local storage. */
61export function setAppState(newState: DevAppState): void {

Callers 4

main.tsFile · 0.90
DevAppLayoutClass · 0.90
ThemeDemoClass · 0.90
setAppStateFunction · 0.85

Calls 3

saveToStorageFunction · 0.85
getItemMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…