zustand-fetching
Advanced tools
Comparing version 2.1.4 to 2.1.5
@@ -14,6 +14,2 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; | ||
}, | ||
processingBeforeSet: () => { | ||
// update data before set | ||
return {}; | ||
}, | ||
}); | ||
@@ -20,0 +16,0 @@ const useUpdateController = leitenRequest(useExampleStore, "user", async (_params) => { |
@@ -7,3 +7,2 @@ import { StoreApi } from "zustand/esm"; | ||
export interface ILeitenListEffects<ITEM, State> { | ||
processingBeforeSet?: (items: ITEM[]) => ITEM[]; | ||
compare?: (left: ITEM, right: ITEM) => boolean; | ||
@@ -10,0 +9,0 @@ sideEffect?: () => void; |
@@ -15,3 +15,3 @@ import { produce } from "immer"; | ||
const draftState = produce(store.getState(), (draft) => { | ||
set(draft, path, (params === null || params === void 0 ? void 0 : params.processingBeforeSet) ? params === null || params === void 0 ? void 0 : params.processingBeforeSet(value) : value); | ||
set(draft, path, value); | ||
}); | ||
@@ -18,0 +18,0 @@ const nextState = (params === null || params === void 0 ? void 0 : params.patchEffect) |
@@ -7,3 +7,2 @@ import { StoreApi } from "zustand/esm"; | ||
export declare const leitenNormalizedList: <Store extends object, P extends DotNestedKeys<Store>>(store: StoreApi<Store>, path: P extends string ? DotNestedValue<Store, P> extends Record<string, unknown> ? P : never : never, params: { | ||
processingBeforeSet?: ((items: NormalizedType<ValueOf<DotNestedValue<Store, P>>>) => ValueOf<DotNestedValue<Store, P>>[]) | undefined; | ||
compare?: ((left: ValueOf<DotNestedValue<Store, P>>, right: ValueOf<DotNestedValue<Store, P>>) => boolean) | undefined; | ||
@@ -10,0 +9,0 @@ sideEffect?: (() => void) | undefined; |
@@ -13,3 +13,3 @@ import { produce } from "immer"; | ||
const draftState = produce(store.getState(), (draft) => { | ||
set(draft, path, (params === null || params === void 0 ? void 0 : params.processingBeforeSet) ? params === null || params === void 0 ? void 0 : params.processingBeforeSet(value) : value); | ||
set(draft, path, value); | ||
}); | ||
@@ -16,0 +16,0 @@ const nextState = (params === null || params === void 0 ? void 0 : params.patchEffect) |
@@ -6,3 +6,2 @@ import { StoreApi } from "zustand"; | ||
patchEffect?: (value: VALUE) => Partial<State>; | ||
processingBeforeSet?: (item: VALUE) => VALUE; | ||
sideEffect?: (value: { | ||
@@ -9,0 +8,0 @@ prev: VALUE; |
@@ -15,5 +15,2 @@ import { produce } from "immer"; | ||
const prev = getState(); | ||
const next = (effects === null || effects === void 0 ? void 0 : effects.processingBeforeSet) | ||
? effects.processingBeforeSet(value) | ||
: value; | ||
const draftState = produce(store.getState(), (draft) => { | ||
@@ -26,3 +23,3 @@ set(draft, path, value); | ||
store.setState(nextState); | ||
(_a = effects === null || effects === void 0 ? void 0 : effects.sideEffect) === null || _a === void 0 ? void 0 : _a.call(effects, { prev, next }); | ||
(_a = effects === null || effects === void 0 ? void 0 : effects.sideEffect) === null || _a === void 0 ? void 0 : _a.call(effects, { prev, next: value }); | ||
}; | ||
@@ -29,0 +26,0 @@ const clear = () => { |
@@ -5,3 +5,2 @@ import { StoreApi } from "zustand/esm"; | ||
patchEffect?: (value: VALUE) => Partial<State>; | ||
processingBeforeSet?: (item: VALUE) => Partial<VALUE>; | ||
sideEffect?: (value: { | ||
@@ -8,0 +7,0 @@ prev: VALUE; |
@@ -15,5 +15,2 @@ import { produce } from "immer"; | ||
const prev = getState(); | ||
const next = (effects === null || effects === void 0 ? void 0 : effects.processingBeforeSet) | ||
? { ...value, ...effects.processingBeforeSet(value) } | ||
: value; | ||
const draftState = produce(store.getState(), (draft) => { | ||
@@ -26,3 +23,3 @@ set(draft, path, value); | ||
store.setState(nextState); | ||
(_a = effects === null || effects === void 0 ? void 0 : effects.sideEffect) === null || _a === void 0 ? void 0 : _a.call(effects, { prev, next }); | ||
(_a = effects === null || effects === void 0 ? void 0 : effects.sideEffect) === null || _a === void 0 ? void 0 : _a.call(effects, { prev, next: value }); | ||
}; | ||
@@ -29,0 +26,0 @@ const clear = () => { |
{ | ||
"name": "zustand-fetching", | ||
"version": "2.1.4", | ||
"version": "2.1.5", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "Zustand fetching helpers", |
@@ -61,4 +61,4 @@ # Zustand Fetching Helpers | ||
**leitenRecord**, **leitenPrimitive**, **leitenList** and **leitenNormalizedList** have options with callbacks: | ||
_processingBeforeSet_, _sideEffect_, _patchEffect_. You can use them to extend basic functionality | ||
**leitenRecord**, **leitenPrimitive**, **leitenList** and **leitenNormalizedList** have options with callbacks: _ | ||
sideEffect_ and _patchEffect_. You can use them to extend basic functionality | ||
@@ -85,3 +85,3 @@ **leitenRequest** and **leitenGrouprRequest** have a useful reactions: _fulfilled_, _rejected_, _abort_, _resolved_ | ||
const User = () => { | ||
const status = useLeitenRequests(state => state[useController.key].status) | ||
const status = useController(state => state[useController.key].status) | ||
return <>{status}</> | ||
@@ -88,0 +88,0 @@ } |
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
88902
1800