All Projects → QuiiBz → particule

QuiiBz / particule

Licence: MIT license
Fine-grained atomic React state management library

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to particule

atomic-state
A decentralized state management library for React
Stars: ✭ 54 (+74.19%)
Mutual labels:  state-management, state, recoil
ReduxSimple
Simple Stupid Redux Store using Reactive Extensions
Stars: ✭ 119 (+283.87%)
Mutual labels:  state-management, state, dispatch
riduce
Get rid of your reducer boilerplate! Zero hassle state management that's typed, flexible and scalable.
Stars: ✭ 14 (-54.84%)
Mutual labels:  state-management, state
tstate-machine
TypeScript implementation of State Manager(like StateMachine)
Stars: ✭ 20 (-35.48%)
Mutual labels:  state-management, state
mutable
State containers with dirty checking and more
Stars: ✭ 32 (+3.23%)
Mutual labels:  state-management, state
vue-reactive-store
A VueX alternative : declarative + reactive + centralized way to structure your data store. Inspired by VueX and Vue.js . Compatible with vue-devtools.
Stars: ✭ 27 (-12.9%)
Mutual labels:  state-management, state
okito
Your best flutter coding friend. All in one; state management, navigation management(with dynamic routing), local storage, localization, dependency injection, cool extensions with best usages and with the support of best utilities!
Stars: ✭ 37 (+19.35%)
Mutual labels:  state-management, state
agile
🌌 Global State and Logic Library for JavaScript/Typescript applications
Stars: ✭ 90 (+190.32%)
Mutual labels:  state-management, state
snap-state
State management in a snap 👌
Stars: ✭ 23 (-25.81%)
Mutual labels:  state-management, state
concave
🧐 Lens-like state management (for React).
Stars: ✭ 13 (-58.06%)
Mutual labels:  state-management, state
vue
Vue integration for Nano Stores, a tiny state manager with many atomic tree-shakable stores
Stars: ✭ 25 (-19.35%)
Mutual labels:  state-management, state
teaful
🍵 Tiny, easy and powerful React state management
Stars: ✭ 638 (+1958.06%)
Mutual labels:  state-management, state
temperjs
State management for React, made simple.
Stars: ✭ 15 (-51.61%)
Mutual labels:  state-management, state
xstate
State machines and statecharts for the modern web.
Stars: ✭ 21,286 (+68564.52%)
Mutual labels:  state-management, state
rex-state
Convert hooks into shared states between React components
Stars: ✭ 32 (+3.23%)
Mutual labels:  state-management, state
useSharedState
useSharedState is a simple hook that can be used to share state between multiple React components.
Stars: ✭ 0 (-100%)
Mutual labels:  state-management, state
vuex-but-for-react
A state management library for React, heavily inspired by vuex
Stars: ✭ 96 (+209.68%)
Mutual labels:  state-management, state
atomic-state
Atomic State is a state management library for React
Stars: ✭ 15 (-51.61%)
Mutual labels:  state-management, state
XUI
XUI makes modular, testable architectures for SwiftUI apps a breeze!
Stars: ✭ 100 (+222.58%)
Mutual labels:  state-management, state
react-cool-form
😎 📋 React hooks for forms state and validation, less code more performant.
Stars: ✭ 246 (+693.55%)
Mutual labels:  state-management, state

particule

Fine-grained atomic React state management library

yarn add particule


Particule is an atomic React state management library inspired by the best of Recoil, Jotai and Redux. You can choose which component subscribe to which state and so avoid useless re-render and computations.

Features

  • Super-easy API
  • TypeScript ready
  • Suspense support
  • Minimal footprint (1kB gzipped)
  • Hooks to add functionality

🚀 Examples

Basic

const textAtom = atom('Hello world!')

function App() {
  const [text, setText] = useAtom(textAtom)

  return (
    <>
      <p>{text}</p>
      <button onClick={() => setText('Updated!')}>Update</button>
    </>
  )
}

Fine-grained

const textAtom = atom('Hello world!')

function Text() {
  const text = useGetAtom(textAtom)

  return <p>{text}</p>
}

// Won't re-render!
function Button() {
  const setText = useSetAtom(textAtom)

  return <button onClick={() => setText('Updated!')}>Update</button>
}

// Won't re-render!
function App() {
  return (
    <>
      <Text />
      <Button />
    </>
  )
}

Composition

const eurosAtom = atom(10)
const dollarsAtom = atom(get => get(eurosAtom) * 1.15)

function App() {
  const [euros, setEuros] = useAtom(eurosAtom)
  const [dollars, setDollars] = useAtom(dollarsAtom)

  return (
    <>
      <input onChange={({ target }) => setEuros(target.value)} value={euros} />
      <input onChange={({ target }) => setDollars(target.value)} value={dollars} />
    </>
  )
}

Suspense

const nameAtom = atom(async () => {
  const json = await (await fetch("https://randomuser.me/api/")).json();

  return json.results[0].name.first;
});

function Name() {
  const name = useGetAtom(nameAtom)

  return <p>My name is {name}</p>
}

function App() {
  return (
    <Suspense fallback='Loading...'>
      <Name />
    </Suspense>
  )
}

Dispatch

const counterAtom = atom(0)
const dispatchCounter = dispatch(counterAtom, value => ({
  increment: (newValue: number) => value + newValue,
  decrement: (newValue: number) => value - newValue,
}))

function App() {
  const counter = useGetAtom(counterAtom)

  return (
    <>
      <p>{counter}</p>
      <button onClick={() => dispatchCounter('increment', 1)}>Increment</button>
      <button onClick={() => dispatchCounter('decrement', 1)}>Decrement</button>
    </>
  )
}

Custom atom with hooks

const noZeroAtom = createAtom({
  beforeValueSet: (_, value) => {
    if (value === 0) {
      throw new Error('Cannot set value to 0')
    }

    return value
  }
})

const counterAtom = noZeroAtom(3)

function App() {
  const [count, setCount] = useAtom(counterAtom)

  return (
    <>
      <p>{count}</p>
      <button onClick={() => setCount(count => count - 1)}>Reduce</button>
    </>
  )
}

📚 Documentation

See the website at particule.vercel.app. Hosted on Vercel.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].