Comparing version 1.10.0 to 1.11.0
@@ -8,2 +8,2 @@ import { keyType } from './types'; | ||
*/ | ||
export declare function mutate<S, K = string>(key: K | keyType, nextValue?: S): void; | ||
export declare function mutate<S, K = string>(key: K | keyType, nextValue?: S): any; |
@@ -188,3 +188,3 @@ 'use strict'; | ||
if (store && store.setState) { | ||
store.setState(key, store.state, nextValue); | ||
return store.setState(key, store.state, nextValue); | ||
} else { | ||
@@ -195,2 +195,3 @@ // init state, if no store exist | ||
}); | ||
return nextValue; | ||
} | ||
@@ -197,0 +198,0 @@ } |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e,n=require("react"),r=require("immer"),o=(t=require("mitt"))&&"object"==typeof t&&"default"in t?t.default:t,u=function(){function t(){}return t.set=function(e,n){var r=t.stores[e];r&&r.setState||(t.stores[e]=n)},t.get=function(e){return t.stores[e]},t}();u.stores={},function(t){t.STORE_INITED="STORE_INITED",t.STORE_UPDATED="STORE_UPDATED"}(e||(e={}));var s=o(),i=function(){function t(t){var n=this;this.setters=[],this.setState=function(t,r,o){var u=n.getNextState(r,o);return n.state=u,s.emit(e.STORE_UPDATED,{key:t,nextState:u}),n.state=u,n.setters.forEach((function(t){return t(u)})),u},this.state=t}return t.prototype.getNextState=function(t,e){var n;if("function"!=typeof e)return e;if("object"!=typeof t)return e(t);var o=!0,u=r.produce(t,(function(t){var r=e(t);r!==t&&r&&"object"==typeof r&&(n=r,o=!1)}));return o&&(n=u),n},t}(),f="object"==typeof window&&"object"==typeof document&&9===document.nodeType?n.useLayoutEffect:n.useEffect;exports.Storage=u,exports.getState=function(t){var e=u.get(t);return e?e.state:void 0},exports.mutate=function(t,e){var n=u.get(t);n&&n.setState?n.setState(t,n.state,e):u.set(t,{state:e})},exports.onStoreInit=function(t){s.on(e.STORE_INITED,(function(e){t(e)}))},exports.onStoreUpdate=function(t){s.on(e.STORE_UPDATED,(function(e){t(e)}))},exports.useStore=function(t,r){var o=u.get(t),c=o?o.state:r;u.set(t,new i(c));var a=u.get(t),S=n.useState(c),p=S[0],E=S[1],T=a.setters;return f((function(){T.push(E),function(t){s.emit(e.STORE_INITED,t)}(t)}),[]),n.useEffect((function(){return function(){T.splice(T.indexOf(E),1)}}),[]),[p,function(t){return function(e){return a.setState(t,p,e)}}(t)]}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e,n=require("react"),r=require("immer"),o=(t=require("mitt"))&&"object"==typeof t&&"default"in t?t.default:t,u=function(){function t(){}return t.set=function(e,n){var r=t.stores[e];r&&r.setState||(t.stores[e]=n)},t.get=function(e){return t.stores[e]},t}();u.stores={},function(t){t.STORE_INITED="STORE_INITED",t.STORE_UPDATED="STORE_UPDATED"}(e||(e={}));var s=o(),i=function(){function t(t){var n=this;this.setters=[],this.setState=function(t,r,o){var u=n.getNextState(r,o);return n.state=u,s.emit(e.STORE_UPDATED,{key:t,nextState:u}),n.state=u,n.setters.forEach((function(t){return t(u)})),u},this.state=t}return t.prototype.getNextState=function(t,e){var n;if("function"!=typeof e)return e;if("object"!=typeof t)return e(t);var o=!0,u=r.produce(t,(function(t){var r=e(t);r!==t&&r&&"object"==typeof r&&(n=r,o=!1)}));return o&&(n=u),n},t}(),f="object"==typeof window&&"object"==typeof document&&9===document.nodeType?n.useLayoutEffect:n.useEffect;exports.Storage=u,exports.getState=function(t){var e=u.get(t);return e?e.state:void 0},exports.mutate=function(t,e){var n=u.get(t);return n&&n.setState?n.setState(t,n.state,e):(u.set(t,{state:e}),e)},exports.onStoreInit=function(t){s.on(e.STORE_INITED,(function(e){t(e)}))},exports.onStoreUpdate=function(t){s.on(e.STORE_UPDATED,(function(e){t(e)}))},exports.useStore=function(t,r){var o=u.get(t),c=o?o.state:r;u.set(t,new i(c));var a=u.get(t),S=n.useState(c),p=S[0],E=S[1],T=a.setters;return f((function(){T.push(E),function(t){s.emit(e.STORE_INITED,t)}(t)}),[]),n.useEffect((function(){return function(){T.splice(T.indexOf(E),1)}}),[]),[p,function(t){return function(e){return a.setState(t,p,e)}}(t)]}; | ||
//# sourceMappingURL=stook.cjs.production.min.js.map |
@@ -182,3 +182,3 @@ import { useState, useEffect, useLayoutEffect } from 'react'; | ||
if (store && store.setState) { | ||
store.setState(key, store.state, nextValue); | ||
return store.setState(key, store.state, nextValue); | ||
} else { | ||
@@ -189,2 +189,3 @@ // init state, if no store exist | ||
}); | ||
return nextValue; | ||
} | ||
@@ -191,0 +192,0 @@ } |
{ | ||
"name": "stook", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"description": "A minimalist design state management library for React", | ||
@@ -26,6 +26,6 @@ "license": "MIT", | ||
"dependencies": { | ||
"immer": "^9.0.5", | ||
"immer": "^9.0.12", | ||
"mitt": "^3.0.0" | ||
}, | ||
"gitHead": "5155d18c04d6f9031efdef3adc824258fe0ef8e5" | ||
"gitHead": "5844af4f06a66601f2d1db4054c868db44877b99" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43333
411
Updatedimmer@^9.0.12