Skip to content

Commit

Permalink
Adding zustand-boilerplate to third-party-libraries (#2673)
Browse files Browse the repository at this point in the history
* 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
sagiereder authored Aug 19, 2024
1 parent 4c5cb7c commit 69112dc
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions docs/integrations/third-party-libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 69112dc

Please sign in to comment.