![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
zustand-fetching
Advanced tools
Readme
Introducing several functions that simplify working with zustand and clean up your store from unnecessary actions and states.
The functions described below are well-typed and allow working with nested objects. Zustand suggests writing custom slices and dividing the store into 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.
I propose several helpers that will take on a significant portion of the typical data work in your store. First of all, it is easier to see Live example on codesandbox.io to understand what it is and how it works. In most cases, leiten controllers will help lighten the store and there will be no need to split it into several parts.
Common view
const useStore = create<IState>(() => ({ ... })); //clean store without actions
const useController = leiten[Controller](useStore, "dot.nested.path", [options]);
All actions and states out of your zustand store. Examples
All leitenControllers automatically calculate required type by path and throw typescript error if the specified path does not satisfy the requirements of the controller or the established types. Examples:
- Argument of type '"info.keywords.1"' is not assignable to parameter of type '"info.keywords"'.
- Argument of type 'string' is not assignable to parameter of type 'never'.
Library well tree shaking and have dependencies from immer, lodash-es and nanoid
leitenRecord, leitenPrimitive, leitenList and leitenNormalizedList have options with callbacks: _ sideEffect_ and patchEffect. You can use them to extend basic functionality
leitenRequest and leitenGrouprRequest have a useful reactions: fulfilled, rejected, abort, resolved and action
All requests working with useLeitenRequests. Usually you will never need it, but if you need it, then the record is stored there with all the query parameters. The request key is returned by each leitenRequest
interface IState {
user: IUser | null;
}
const useExampleStore = create<IState>(() => ({
user: null,
}));
const useController = leitenRequest(useExampleStore, "user", getUser);
const User = () => {
const status = useController(state => state[useController.key].status)
return <>{status}</>
}
leitenMap also can be helpful, example
leitenGroupRequest return overloaded hook
interface IState {
cards: Record<string, ICard>;
}
const useExampleStore = create<IState>(() => ({
cards: {},
}));
export const useGroupController = leitenGroupRequest(
useExampleStore,
"cards",
async (props: ILeitenGroupRequestParams<string>) => {
return getCard(props.params);
},
);
const status = useGroupController(id, (state) => state.status); //First param is key, better option
or
const requests = useGroupController((state) => state); // Record with all requests
Wrappers for ContextStore and ResettableStore
Here are examples of our helpers for slices
FAQs
Zustand state manager controllers
The npm package zustand-fetching receives a total of 87 weekly downloads. As such, zustand-fetching popularity was classified as not popular.
We found that zustand-fetching demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.