From 69112dcfffa8a25aedb7f4be91218d2c5694a1ec Mon Sep 17 00:00:00 2001 From: sagiereder <34967034+sagiereder@users.noreply.github.com> Date: Mon, 19 Aug 2024 04:20:23 +0300 Subject: [PATCH] Adding zustand-boilerplate to third-party-libraries (#2673) * Adding zustand-boilerplate to third-party-libraries Hi, I'm the maker of zustand-boilerplate. It's a small utility that generates getters, setters based on a class representing a zustand store. I'd like to add it to the list of 3rd party libraries to let people know. I've attached an example: ``` import { create } from "zustand" import * as Z from "zustand-boilerplate" interface Bear { name: string } class BearStore { @Z.Boolean() isDangerous = false @Z.Number() count = 0 @Z.Array() bears: Bear[] = [] // // Notice you have to set a default value and apply the decorator // to properties for generated actions to work // @Z.Any() mainBear: Bear | undefined = undefined @Z.String() userName: string | undefined = undefined } const bearStoreWithActions = Z.generateStoreWithActions(BearStore) export const store = create(bearStoreWithActions) // The following will automatically work now (fully typed) // store.getState().getBears() -> Bear[] // store.getState().setBears(bears) // ... ``` * chore: a-z ordering --- docs/integrations/third-party-libraries.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/integrations/third-party-libraries.md b/docs/integrations/third-party-libraries.md index f1d650a55b..0a2a8ffb68 100644 --- a/docs/integrations/third-party-libraries.md +++ b/docs/integrations/third-party-libraries.md @@ -37,6 +37,7 @@ This can be done using third-party libraries created by the community. - [zukeeper](https://github.com/oslabs-beta/Zukeeper) - Native devtools with state and action tracking, diffing, tree display, and time travel - [zundo](https://github.com/charkour/zundo) — 🍜 Undo and redo middleware for Zustand, enabling time-travel in your apps. - [zustand-ards](https://github.com/ivoilic/zustand-ards) - 💁 Simple opinionated utilities for example alternative selector formats and default shallow hooks +- [zustand-boilerplate](https://github.com/sagiereder/zustand-boilerplate) - A tool that automatically generates getters, setters and more for your zustand store. - [zustand-computed](https://github.com/chrisvander/zustand-computed) — A Zustand middleware to create computed states. - [zustand-computed-state](https://github.com/yasintz/zustand-computed-state) — Simple middleware to add computed states. - [zustand-constate](https://github.com/ntvinhit/zustand-constate) — Context-based state management based on Zustand and taking ideas from Constate.