Blame view

天文台pc/tianwentai-ui/node_modules/@mui/system/esm/cssVars/localStorageManager.d.ts 1.08 KB
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  export interface StorageManager {
    (options: {
      key: string;
      storageWindow?: Window | null | undefined;
    }): {
      /**
       * Function to get the value from the storage
       * @param defaultValue The default value to be returned if the key is not found
       * @returns The value from the storage or the default value
       */
      get(defaultValue: any): any;
      /**
       * Function to set the value in the storage
       * @param value The value to be set
       * @returns void
       */
      set(value: any): void;
      /**
       * Function to subscribe to the value of the specified key triggered by external events
       * @param handler The function to be called when the value changes
       * @returns A function to unsubscribe the handler
       * @example
       * React.useEffect(() => {
       *  const unsubscribe = storageManager.subscribe((value) => {
       *    console.log(value);
       *  });
       *  return unsubscribe;
       * }, []);
       */
      subscribe(handler: (value: any) => void): () => void;
    };
  }
  declare const localStorageManager: StorageManager;
  export default localStorageManager;