@shipt/osmosis
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -1,2 +0,2 @@ | ||
export type useCustomHook = () => any; | ||
export type useCustomHook = (props: any) => any; | ||
export type SetupStoreConfig = { | ||
@@ -20,2 +20,3 @@ /** | ||
* @callback useCustomHook | ||
* @param {Object} props | ||
* @returns {Object} | ||
@@ -22,0 +23,0 @@ */ |
@@ -21,2 +21,3 @@ "use strict"; | ||
* @callback useCustomHook | ||
* @param {Object} props | ||
* @returns {Object} | ||
@@ -48,11 +49,7 @@ */ | ||
var storeRef = { | ||
state: {} | ||
}; // If proxy is supported | ||
var storeRef = {}; // If proxy is supported | ||
var storeProxy; | ||
var storeProxyObject = { | ||
ref: { | ||
state: {} | ||
} | ||
ref: {} | ||
}; | ||
@@ -62,3 +59,4 @@ | ||
return function (props) { | ||
var store = useCustomHook(); | ||
var storeKey = props.storeKey; | ||
var store = useCustomHook(props); | ||
if (!!store.Context) throw new Error("'Context' property is protected and cannot exist on a store object"); | ||
@@ -68,6 +66,12 @@ if (!!store.Provider) throw new Error("'Provider' property is protected and cannot exist on a store object"); | ||
if (storeProxy) { | ||
storeProxyObject.ref = store; | ||
if (storeKey) { | ||
storeProxyObject.ref[storeKey] = store; | ||
} else storeProxyObject.ref = store; | ||
} else { | ||
for (var key in store) { | ||
storeRef[key] = store[key]; | ||
if (storeKey) { | ||
storeRef[storeKey] = store; | ||
} else { | ||
for (var key in store) { | ||
storeRef[key] = store[key]; | ||
} | ||
} | ||
@@ -74,0 +78,0 @@ } |
@@ -74,4 +74,6 @@ "use strict"; | ||
setState(function (state) { | ||
var _persistedValue; | ||
return { | ||
value: persistedValue || state.value, | ||
value: (_persistedValue = persistedValue) !== null && _persistedValue !== void 0 ? _persistedValue : state.value, | ||
isLoaded: true | ||
@@ -78,0 +80,0 @@ }; |
{ | ||
"name": "@shipt/osmosis", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "A lightweight state management library for React and React Native", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
20338
322