zustand-kit 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -4
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/package.json +1 -1
- package/types/index.d.ts +55 -20
package/README.md
CHANGED
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
- 🚀 **简单易用** - 最小化的 API 设计,易于上手
|
|
10
10
|
- 🎯 **类型安全** - 完整的 TypeScript 支持
|
|
11
11
|
- 💾 **持久化** - 内置 localStorage/sessionStorage 支持
|
|
12
|
+
- 🔍 **开发者工具** - 开发环境自动集成 Redux DevTools
|
|
12
13
|
- ⚡ **高性能** - 基于 Zustand,性能卓越
|
|
13
14
|
- 🔄 **灵活更新** - 支持对象部分更新和函数式更新
|
|
14
|
-
- 🎨
|
|
15
|
+
- 🎨 **智能选择器** - 细粒度订阅,自动检测返回值类型并优化性能
|
|
15
16
|
- 🌐 **非 React 环境支持** - 提供独立的 API 用于非组件场景
|
|
16
17
|
|
|
17
18
|
## 📦 安装
|
|
@@ -77,7 +78,7 @@ function UserProfile() {
|
|
|
77
78
|
import { useGlobalState } from 'zustand-kit';
|
|
78
79
|
|
|
79
80
|
function Settings() {
|
|
80
|
-
// 使用 localStorage
|
|
81
|
+
// 使用 localStorage 持久化(开发环境自动启用 DevTools)
|
|
81
82
|
const [settings, setSettings] = useGlobalState(
|
|
82
83
|
'settings',
|
|
83
84
|
{ theme: 'dark', lang: 'zh-CN' },
|
|
@@ -105,6 +106,29 @@ function Settings() {
|
|
|
105
106
|
}
|
|
106
107
|
```
|
|
107
108
|
|
|
109
|
+
### Redux DevTools 集成
|
|
110
|
+
|
|
111
|
+
在开发环境下,所有全局状态会自动集成到统一的 Redux DevTools 视图中,便于调试:
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
import { useGlobalState } from 'zustand-kit';
|
|
115
|
+
|
|
116
|
+
// 开发环境自动启用 DevTools(默认行为)
|
|
117
|
+
const [data, setData] = useGlobalState('data', { count: 0 });
|
|
118
|
+
|
|
119
|
+
// 禁用 DevTools(即使在开发环境)
|
|
120
|
+
const [privateData, setPrivateData] = useGlobalState('private', {}, {
|
|
121
|
+
enableDevtools: false
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// 强制启用 DevTools(生产环境,不推荐)
|
|
125
|
+
const [debugData, setDebugData] = useGlobalState('debug', {}, {
|
|
126
|
+
enableDevtools: true
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**注意:** 所有全局状态会聚合到一个名为 `GlobalStates (All)` 的 DevTools 实例中,每个状态以其 key 作为属性显示,方便统一查看和调试所有状态。
|
|
131
|
+
|
|
108
132
|
### 选择器模式(性能优化)
|
|
109
133
|
|
|
110
134
|
```tsx
|
|
@@ -112,6 +136,7 @@ import { useGlobalSelector } from 'zustand-kit';
|
|
|
112
136
|
|
|
113
137
|
function UserName() {
|
|
114
138
|
// 仅订阅 user.name,其他字段变化不会触发重渲染
|
|
139
|
+
// 自动检测:基本类型使用 Object.is
|
|
115
140
|
const userName = useGlobalSelector('user', (state) => state.name);
|
|
116
141
|
|
|
117
142
|
return <p>用户名: {userName}</p>;
|
|
@@ -123,6 +148,38 @@ function UserEmail() {
|
|
|
123
148
|
|
|
124
149
|
return <p>邮箱: {userEmail}</p>;
|
|
125
150
|
}
|
|
151
|
+
|
|
152
|
+
// 自动检测:对象返回值自动使用浅比较
|
|
153
|
+
function UserInfo() {
|
|
154
|
+
const userInfo = useGlobalSelector(
|
|
155
|
+
'user',
|
|
156
|
+
(state) => ({ name: state.name, email: state.email })
|
|
157
|
+
// 无需指定 'shallow',自动检测对象类型并使用浅比较
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<div>
|
|
162
|
+
<p>姓名: {userInfo.name}</p>
|
|
163
|
+
<p>邮箱: {userInfo.email}</p>
|
|
164
|
+
</div>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// 显式指定 'shallow' 模式
|
|
169
|
+
function UserInfoExplicit() {
|
|
170
|
+
const userInfo = useGlobalSelector(
|
|
171
|
+
'user',
|
|
172
|
+
(state) => ({ name: state.name, email: state.email }),
|
|
173
|
+
'shallow' // 显式指定浅比较
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<div>
|
|
178
|
+
<p>姓名: {userInfo.name}</p>
|
|
179
|
+
<p>邮箱: {userInfo.email}</p>
|
|
180
|
+
</div>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
126
183
|
```
|
|
127
184
|
|
|
128
185
|
### 仅获取 Setter(不订阅状态)
|
|
@@ -185,16 +242,25 @@ resetGlobalState('counter');
|
|
|
185
242
|
- `options?: UseGlobalStateOptions` - 可选配置
|
|
186
243
|
- `storage?: 'localStorage' | 'sessionStorage' | 'none'` - 持久化类型(默认 'none')
|
|
187
244
|
- `storageKey?: string` - 存储键前缀(默认 'global-state')
|
|
245
|
+
- `enableDevtools?: boolean` - 是否启用 Redux DevTools(开发环境默认 true,生产环境默认 false)
|
|
188
246
|
|
|
189
247
|
**返回:** `[state, setState, resetState]`
|
|
190
248
|
|
|
191
|
-
|
|
249
|
+
**注意:** 对于对象类型的状态,`setState` 支持部分更新。例如:`setUser({ name: 'Jane' })` 只会更新 `name` 字段,其他字段保持不变。
|
|
250
|
+
|
|
251
|
+
### `useGlobalSelector<T, R>(key, selector, equalityMode?)`
|
|
192
252
|
|
|
193
|
-
|
|
253
|
+
使用选择器订阅状态的特定部分。支持自动检测返回值类型并选择合适的比较模式。
|
|
194
254
|
|
|
195
255
|
**参数:**
|
|
196
256
|
- `key: string` - 状态键
|
|
197
257
|
- `selector: (state: T) => R` - 选择器函数
|
|
258
|
+
- `equalityMode?: 'shallow' | false` - 可选的比较模式
|
|
259
|
+
- `undefined` (默认):自动检测返回值类型
|
|
260
|
+
- 基本类型:使用 `Object.is`
|
|
261
|
+
- 对象/数组:使用浅比较
|
|
262
|
+
- `'shallow'`:强制使用浅比较
|
|
263
|
+
- `false`:强制使用 `Object.is` 比较(即使对象类型)
|
|
198
264
|
|
|
199
265
|
**返回:** 选择的值
|
|
200
266
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }var x=Object.defineProperty,E=Object.defineProperties;var N=Object.getOwnPropertyDescriptors;var h=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable;var G=(t,e,o)=>e in t?x(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,T=(t,e)=>{for(var o in e||(e={}))O.call(e,o)&&G(t,o,e[o]);if(h)for(var o of h(e))D.call(e,o)&&G(t,o,e[o]);return t},A=(t,e)=>E(t,N(e));var _react = require('react'); var m = _interopRequireWildcard(_react);var _zustand = require('zustand');var _middleware = require('zustand/middleware');var _shallow = require('zustand/react/shallow');var a=new Map,i=null;function C(){return i||(i=_zustand.create.call(void 0, )(_middleware.devtools.call(void 0, ()=>({}),{name:"GlobalStates (All)"}))),i}function p(t,e){if(i){let o=i.getState();i.setState(A(T({},o),{[t]:e}))}}function X(){a.clear(),i=null}function k(t,e,o){let{storage:n="none",storageKey:u="global-state",enableDevtools:r=process.env.NODE_ENV!=="production"}=o||{};if(!a.has(t)){let c=typeof e=="object"&&e!==null&&!Array.isArray(e),V=(S,K)=>({value:e,setValue:l=>{typeof l=="function"?S(d=>{let f=l(d.value);return r&&p(t,f),{value:f}}):c&&typeof l=="object"&&l!==null?S(d=>{let f=T(T({},d.value),l);return r&&p(t,f),{value:f}}):(S({value:l}),r&&p(t,l))},reset:()=>{S({value:e}),r&&p(t,e)}}),g;if(n!=="none"){let S=n==="localStorage"?localStorage:sessionStorage;g=_zustand.create.call(void 0, )(_middleware.persist.call(void 0, V,{name:`${u}-${t}`,storage:_middleware.createJSONStorage.call(void 0, ()=>S)}))}else g=_zustand.create.call(void 0, V);a.set(t,g),r&&(C(),p(t,e))}let s=a.get(t),b=s(c=>c.value),B=_react.useMemo.call(void 0, ()=>c=>s.getState().setValue(c),[s]),R=_react.useMemo.call(void 0, ()=>()=>s.getState().reset(),[s]);return[b,B,R]}function Y(t,e,o){let n=a.get(t);if(!n)throw new Error(`Global state with key "${t}" not found. Initialize it with useGlobalState first.`);let u=_react.useRef.call(void 0, e);_react.useEffect.call(void 0, ()=>{u.current=e});let r=_react.useCallback.call(void 0, s=>u.current(s.value),[]);if(o===void 0){let s=r(n.getState());return s!==null&&typeof s=="object"&&!m.isValidElement(s)?n(_shallow.useShallow.call(void 0, r)):n(r)}return n(o==="shallow"?_shallow.useShallow.call(void 0, r):r)}function Z(t){let e=a.get(t);if(!e)throw new Error(`Global state with key "${t}" not found. Initialize it with useGlobalState first.`);return _react.useMemo.call(void 0, ()=>o=>e.getState().setValue(o),[e])}function q(t){let e=a.get(t);return e==null?void 0:e.getState().value}function ee(t,e){let o=a.get(t);if(!o){process.env.NODE_ENV!=="production"&&console.warn(`Global state with key "${t}" not found. Initialize it with useGlobalState first.`);return}o.getState().setValue(e)}function te(t,e){let o=a.get(t);if(!o)return process.env.NODE_ENV!=="production"&&console.warn(`Global state with key "${t}" not found. Initialize it with useGlobalState first.`),()=>{};let n=o.getState().value;return o.subscribe(u=>{let r=u.value;Object.is(r,n)||(e(r,n),n=r)})}function oe(t){let e=a.get(t);if(!e){process.env.NODE_ENV!=="production"&&console.warn(`Global state with key "${t}" not found. Initialize it with useGlobalState first.`);return}e.getState().reset()}var re=k;exports.__clearAllStates__ = X; exports.default = re; exports.getGlobalState = q; exports.resetGlobalState = oe; exports.setGlobalState = ee; exports.subscribeGlobalState = te; exports.useGlobalSelector = Y; exports.useGlobalSetter = Z; exports.useGlobalState = k;
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var x=Object.defineProperty,E=Object.defineProperties;var N=Object.getOwnPropertyDescriptors;var h=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable;var G=(t,e,o)=>e in t?x(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,T=(t,e)=>{for(var o in e||(e={}))O.call(e,o)&&G(t,o,e[o]);if(h)for(var o of h(e))D.call(e,o)&&G(t,o,e[o]);return t},A=(t,e)=>E(t,N(e));import*as m from"react";import{create as v}from"zustand";import{persist as _,createJSONStorage as $,devtools as I}from"zustand/middleware";import{useMemo as w,useRef as j,useCallback as y,useEffect as z}from"react";import{useShallow as U}from"zustand/react/shallow";var a=new Map,i=null;function C(){return i||(i=v()(I(()=>({}),{name:"GlobalStates (All)"}))),i}function p(t,e){if(i){let o=i.getState();i.setState(A(T({},o),{[t]:e}))}}function X(){a.clear(),i=null}function k(t,e,o){let{storage:n="none",storageKey:u="global-state",enableDevtools:r=process.env.NODE_ENV!=="production"}=o||{};if(!a.has(t)){let c=typeof e=="object"&&e!==null&&!Array.isArray(e),V=(S,K)=>({value:e,setValue:l=>{typeof l=="function"?S(d=>{let f=l(d.value);return r&&p(t,f),{value:f}}):c&&typeof l=="object"&&l!==null?S(d=>{let f=T(T({},d.value),l);return r&&p(t,f),{value:f}}):(S({value:l}),r&&p(t,l))},reset:()=>{S({value:e}),r&&p(t,e)}}),g;if(n!=="none"){let S=n==="localStorage"?localStorage:sessionStorage;g=v()(_(V,{name:`${u}-${t}`,storage:$(()=>S)}))}else g=v(V);a.set(t,g),r&&(C(),p(t,e))}let s=a.get(t),b=s(c=>c.value),B=w(()=>c=>s.getState().setValue(c),[s]),R=w(()=>()=>s.getState().reset(),[s]);return[b,B,R]}function Y(t,e,o){let n=a.get(t);if(!n)throw new Error(`Global state with key "${t}" not found. Initialize it with useGlobalState first.`);let u=j(e);z(()=>{u.current=e});let r=y(s=>u.current(s.value),[]);if(o===void 0){let s=r(n.getState());return s!==null&&typeof s=="object"&&!m.isValidElement(s)?n(U(r)):n(r)}return n(o==="shallow"?U(r):r)}function Z(t){let e=a.get(t);if(!e)throw new Error(`Global state with key "${t}" not found. Initialize it with useGlobalState first.`);return w(()=>o=>e.getState().setValue(o),[e])}function q(t){let e=a.get(t);return e==null?void 0:e.getState().value}function ee(t,e){let o=a.get(t);if(!o){process.env.NODE_ENV!=="production"&&console.warn(`Global state with key "${t}" not found. Initialize it with useGlobalState first.`);return}o.getState().setValue(e)}function te(t,e){let o=a.get(t);if(!o)return process.env.NODE_ENV!=="production"&&console.warn(`Global state with key "${t}" not found. Initialize it with useGlobalState first.`),()=>{};let n=o.getState().value;return o.subscribe(u=>{let r=u.value;Object.is(r,n)||(e(r,n),n=r)})}function oe(t){let e=a.get(t);if(!e){process.env.NODE_ENV!=="production"&&console.warn(`Global state with key "${t}" not found. Initialize it with useGlobalState first.`);return}e.getState().reset()}var re=k;export{X as __clearAllStates__,re as default,q as getGlobalState,oe as resetGlobalState,ee as setGlobalState,te as subscribeGlobalState,Y as useGlobalSelector,Z as useGlobalSetter,k as useGlobalState};
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file src/index.tsx
|
|
3
|
-
* @author leon.wang
|
|
4
|
-
*/
|
|
5
1
|
/**
|
|
6
2
|
* Clear all global states (for testing purposes)
|
|
7
3
|
* @internal
|
|
@@ -11,6 +7,10 @@ export declare function __clearAllStates__(): void;
|
|
|
11
7
|
* Storage type for persistence
|
|
12
8
|
*/
|
|
13
9
|
export type StorageType = 'localStorage' | 'sessionStorage' | 'none';
|
|
10
|
+
/**
|
|
11
|
+
* Helper type for setter value - supports partial updates for objects
|
|
12
|
+
*/
|
|
13
|
+
type SetterValue<T> = T extends Record<string, unknown> ? Partial<T> | ((prev: T) => T) : T | ((prev: T) => T);
|
|
14
14
|
/**
|
|
15
15
|
* Options for useGlobalState
|
|
16
16
|
*/
|
|
@@ -25,14 +25,19 @@ export interface UseGlobalStateOptions {
|
|
|
25
25
|
* @default 'global-state'
|
|
26
26
|
*/
|
|
27
27
|
storageKey?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Enable Redux DevTools integration (aggregated view only)
|
|
30
|
+
* @default true in development, false in production
|
|
31
|
+
*/
|
|
32
|
+
enableDevtools?: boolean;
|
|
28
33
|
}
|
|
29
34
|
/**
|
|
30
35
|
* Universal global state hook - supports both simple values and objects
|
|
31
|
-
* Performance optimized with selector pattern
|
|
36
|
+
* Performance optimized with selector pattern and automatic Redux DevTools integration
|
|
32
37
|
*
|
|
33
38
|
* @param key - Unique key for the state
|
|
34
39
|
* @param initialState - Initial state (any type)
|
|
35
|
-
* @param options - Configuration options including persistence
|
|
40
|
+
* @param options - Configuration options including persistence and devtools
|
|
36
41
|
* @returns [state, setState, resetState]
|
|
37
42
|
*
|
|
38
43
|
* @example
|
|
@@ -45,42 +50,72 @@ export interface UseGlobalStateOptions {
|
|
|
45
50
|
* const [user, setUser, resetUser] = useGlobalState('user', {
|
|
46
51
|
* name: 'John',
|
|
47
52
|
* email: 'john@example.com',
|
|
53
|
+
* age: 30
|
|
48
54
|
* });
|
|
49
|
-
* setUser({ name: 'Jane' }); // Partial update
|
|
55
|
+
* setUser({ name: 'Jane' }); // Partial update - only updates name field
|
|
56
|
+
* setUser(prev => ({ ...prev, age: prev.age + 1 })); // Functional update
|
|
50
57
|
*
|
|
51
|
-
* // With localStorage persistence
|
|
58
|
+
* // With localStorage persistence (DevTools enabled by default in development)
|
|
52
59
|
* const [settings, setSettings] = useGlobalState('settings', { theme: 'dark' }, {
|
|
53
60
|
* storage: 'localStorage'
|
|
54
61
|
* });
|
|
55
62
|
*
|
|
56
|
-
* // With sessionStorage persistence
|
|
63
|
+
* // With sessionStorage persistence and custom storage key
|
|
57
64
|
* const [tempData, setTempData] = useGlobalState('temp', { foo: 'bar' }, {
|
|
58
65
|
* storage: 'sessionStorage',
|
|
59
66
|
* storageKey: 'my-app'
|
|
60
67
|
* });
|
|
61
68
|
*
|
|
69
|
+
* // Disable aggregated DevTools in development
|
|
70
|
+
* const [privateData, setPrivateData] = useGlobalState('private', {}, {
|
|
71
|
+
* enableDevtools: false
|
|
72
|
+
* });
|
|
73
|
+
*
|
|
74
|
+
* // Force enable aggregated DevTools in production (not recommended)
|
|
75
|
+
* const [debugData, setDebugData] = useGlobalState('debug', {}, {
|
|
76
|
+
* enableDevtools: true
|
|
77
|
+
* });
|
|
78
|
+
*
|
|
62
79
|
* // For non-React usage, see: getGlobalState, setGlobalState, subscribeGlobalState, resetGlobalState
|
|
63
80
|
*/
|
|
64
|
-
export declare function useGlobalState<T>(key: string, initialState: T, options?: UseGlobalStateOptions): [
|
|
65
|
-
T,
|
|
66
|
-
(value: T extends Record<string, unknown> ? Partial<T> | ((prev: T) => T) : T | ((prev: T) => T)) => void,
|
|
67
|
-
() => void
|
|
68
|
-
];
|
|
81
|
+
export declare function useGlobalState<T>(key: string, initialState: T, options?: UseGlobalStateOptions): [T, (value: SetterValue<T>) => void, () => void];
|
|
69
82
|
/**
|
|
70
83
|
* Advanced hook with custom selector for fine-grained subscriptions
|
|
71
84
|
* Only re-renders when selected value changes
|
|
85
|
+
* Automatically detects return type and uses appropriate comparison mode
|
|
86
|
+
*
|
|
87
|
+
* @param key - Global state key
|
|
88
|
+
* @param selector - Function to select part of the state
|
|
89
|
+
* @param equalityMode - Optional comparison mode:
|
|
90
|
+
* - undefined (default): Auto-detect based on return type (shallow for objects/arrays, Object.is for primitives)
|
|
91
|
+
* - 'shallow': Force shallow comparison
|
|
92
|
+
* - false: Force Object.is comparison
|
|
72
93
|
*
|
|
73
94
|
* @example
|
|
74
|
-
* //
|
|
95
|
+
* // Auto mode: uses Object.is for primitive
|
|
75
96
|
* const userName = useGlobalSelector('user', (state) => state.name);
|
|
76
97
|
*
|
|
77
|
-
* //
|
|
78
|
-
* const
|
|
98
|
+
* // Auto mode: uses shallow for object
|
|
99
|
+
* const userInfo = useGlobalSelector(
|
|
79
100
|
* 'user',
|
|
80
101
|
* (state) => ({ name: state.name, email: state.email })
|
|
81
102
|
* );
|
|
103
|
+
*
|
|
104
|
+
* // Force shallow comparison
|
|
105
|
+
* const userInfo = useGlobalSelector(
|
|
106
|
+
* 'user',
|
|
107
|
+
* (state) => ({ name: state.name, email: state.email }),
|
|
108
|
+
* 'shallow'
|
|
109
|
+
* );
|
|
110
|
+
*
|
|
111
|
+
* // Force Object.is comparison (even for objects)
|
|
112
|
+
* const userInfo = useGlobalSelector(
|
|
113
|
+
* 'user',
|
|
114
|
+
* (state) => ({ name: state.name, email: state.email }),
|
|
115
|
+
* false
|
|
116
|
+
* );
|
|
82
117
|
*/
|
|
83
|
-
export declare function useGlobalSelector<T, R>(key: string, selector: (state: T) => R): R;
|
|
118
|
+
export declare function useGlobalSelector<T, R>(key: string, selector: (state: T) => R, equalityMode?: 'shallow' | false): R;
|
|
84
119
|
/**
|
|
85
120
|
* Hook to get setter function only (doesn't subscribe to state changes)
|
|
86
121
|
* Useful when you only need to update state without reading it
|
|
@@ -90,7 +125,7 @@ export declare function useGlobalSelector<T, R>(key: string, selector: (state: T
|
|
|
90
125
|
* setCount(5);
|
|
91
126
|
* setCount(prev => prev + 1);
|
|
92
127
|
*/
|
|
93
|
-
export declare function useGlobalSetter<T>(key: string): (value:
|
|
128
|
+
export declare function useGlobalSetter<T>(key: string): (value: SetterValue<T>) => void;
|
|
94
129
|
/**
|
|
95
130
|
* Get global state value (for non-React usage)
|
|
96
131
|
* @example
|
|
@@ -104,7 +139,7 @@ export declare function getGlobalState<T>(key: string): T | undefined;
|
|
|
104
139
|
* setGlobalState('counter', prev => prev + 1);
|
|
105
140
|
* setGlobalState('user', { name: 'Jane' }); // Partial update for objects
|
|
106
141
|
*/
|
|
107
|
-
export declare function setGlobalState<T>(key: string, value:
|
|
142
|
+
export declare function setGlobalState<T>(key: string, value: SetterValue<T>): void;
|
|
108
143
|
/**
|
|
109
144
|
* Subscribe to global state changes (for non-React usage)
|
|
110
145
|
* Returns unsubscribe function
|