Socket
Socket
Sign inDemoInstall

zustand-fetching

Package Overview
Dependencies
11
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.4 to 2.0.5

7

dist/examples/controllers/1_Controller_Request.js

@@ -9,8 +9,3 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";

}));
const useGetController = leitenRequest(useExampleStore, "user", (value, extraArgument) => getUser(value, extraArgument === null || extraArgument === void 0 ? void 0 : extraArgument.signal), // some async function
{
fulfilled: (result, params) => {
console.log("everything ok", result.name, params);
},
});
const useGetController = leitenRequest(useExampleStore, "user", (value) => getUser(value));
const Example = () => {

@@ -17,0 +12,0 @@ const status = useGetController((state) => state.status);

2

dist/examples/store/ResettableStore.js

@@ -5,3 +5,3 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";

products: [],
setProducts: (myProducts) => set((state) => ({ ...state, products: myProducts })),
setProducts: (myProducts) => set({ products: myProducts }),
}));

@@ -8,0 +8,0 @@ const ResettableComponent = () => {

{
"name": "zustand-fetching",
"version": "2.0.4",
"version": "2.0.5",
"private": false,

@@ -5,0 +5,0 @@ "description": "Zustand fetching helpers",

@@ -9,23 +9,36 @@ # Zustand Fetching Helpers

several parts. However, in most cases, we need to divide the store into several parts because we add a lot of
unnecessary data, which can visually overload
it.
unnecessary data, which can visually overload it.
I propose several helpers that will take on a significant portion of the typical data work in your store. First, it is
easier to see [examples](https://github.com/Hecmatyar/zustand-fetching/tree/main/src/examples/controllers) to understand
what it is and how it can help.
what it is and how it can help. In most cases, helpers will help lighten the store and there will be no need to split it
into several parts
Common view
```tsx
const useStore = create<IState>(() => ({ ... }));
const useController = leiten[Controller](useStore, "dot.nested.path", [options]);
const Component = () => {
const status = useController(state => statet.status);
return status !== "loading" ? <>content</> : null;
}
```
All actions and states out of your **zustand** store
- [leitenRequest](https://github.com/Hecmatyar/zustand-fetching/blob/main/src/examples/controllers/1_Controller_Request.tsx)
help you to handle request (any async function) and catch errors, return **hook** with params of request, and have
methods _action_, _clear_, _abort_ and _set_.
methods: _action_, _clear_, _abort_ and _set_.
- [leitenGroupRequest](https://github.com/Hecmatyar/zustand-fetching/blob/main/src/examples/controllers/6_Controller_GroupRequest.tsx)
handle a lot of similar requests dynamically, return **hook** with 2 overloads and have methods _call_ and _clear_.
handle a lot of similar requests dynamically, return **hook** with 2 overloads and have methods: _call_ and _clear_.
- [leitenRecord](https://github.com/Hecmatyar/zustand-fetching/blob/main/src/examples/controllers/2_Controller_Record.tsx)
working with objects, have methods _set_, _patch_ and _clear_.
- [leitenPrimitive](https://github.com/Hecmatyar/zustand-fetching/blob/main/src/examples/controllers/3_Controller_Primitive.tsx)
working with data like with primitive value, but it can be object, function or primitives. Have methods _set_ and _
working with data like with primitive value, but it can be object, function or primitives. Have methods: _set_ and _
clear_.
- [leitenList](https://github.com/Hecmatyar/zustand-fetching/blob/main/src/examples/controllers/4_Controller_List.tsx)
working with array. Have methods _set_, _clear_, _add_, _update_, _remove_, _toggle_ and _filter_. If array item is an
object then
set **compare** function in the controller's options (third parameter).
working with array, have methods: _set_, _clear_, _add_, _update_, _remove_, _toggle_ and _filter_. If array item is
an
object then need to set **compare** function in the controller's options (third parameter).
- [leitenNormalizedList](https://github.com/Hecmatyar/zustand-fetching/blob/main/src/examples/controllers/4_Controller_List.tsx)

@@ -35,3 +48,3 @@ is the same as leitenList but working with normalized state.

help to work with modals, have built in modal manager (if you want to open modal in cascade). Return hooks
with [openState, hiddenState], have methods _open_, _close_ and _action_.
with [openState, hiddenState], have methods: _open_, _close_ and _action_.

@@ -53,2 +66,4 @@ > All leitenControllers automatically calculate required type by path and **throw typescript error** if the specified

**leitenRequest** and **leitenGrouprRequest** have reactions: _fulfilled_, _rejected_, _abort_, _resolved_ and _action_
### Request

@@ -112,2 +127,2 @@

Here are examples of our helpers
for [slices](https://github.com/Hecmatyar/zustand-fetching/tree/main/src/examples/slices)
for [slices](https://github.com/Hecmatyar/zustand-fetching/tree/main/src/examples/slices)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc