Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information