Getting started

zustandarrow-up-right is an amazing library that keeps state management as simple as you would have always loved it to be. zfy has been built on top of it to provide a useful set of tools to make that experience even more delightful.

πŸ—οΈ Installation

yarn add @colorfy-software/zfy

🌺 Features

  • Fully typed with TypeScript

  • Standardized access/update API backed by Immer

  • Ability to manage & consume multiple stores at once

  • Simple API for store creation with custom middlewares

  • Out-of-the-box persist gate component & rehydration hook

  • Logger, persist & subscribe middlewares available via a simple flag

πŸ’» Usage

  1. 🐣 Create your stores

import {
  PersistGate,
  createStore,
  initStores,
  useRehydrate,
} from '@colorfy-software/zfy'
import AsyncStorage from '@react-native-async-storage/async-storage'

const simpleStore = createStore('groceries', ['kimchi', 'bok choy', 'tteokbokki' ])
const persistedStore = createStore(
  'user',
  { firstName: 'Jolyne' },
  { persist: { getStorage: () => AsyncStorage } },
)

2. ♻️ Rehydrate your data if needed

3. πŸ“¦ Bundle your stores as you please

4. βš›οΈ Use the bundled/individual stores in your components

5. πŸ†• Update your data immutably (thanks to Immerarrow-up-right) from wherever

6. 🧹 Reset it all once your user is done

πŸ’« Acknowledgments

As you can imagine: major thanks to the team of contributors behind zustandarrow-up-right for such an amazing library! zfy also exists thanks to the folks working on Immerarrow-up-right who made it so easy to deal with immutable state updates.

Last updated