@stateloom/store
v1.0.0-alpha.0
Published
Store-based state management for StateLoom
Readme
@stateloom/store
Store-based state management for StateLoom. Familiar to Zustand and Redux Toolkit users.
Install
pnpm add @stateloom/core @stateloom/storeQuick Start
import { createStore } from '@stateloom/store';
const counter = createStore((set, get) => ({
count: 0,
increment: () => set((s) => ({ count: s.count + 1 })),
decrement: () => set((s) => ({ count: s.count - 1 })),
reset: () => set({ count: 0 }),
}));
counter.getState().count; // 0
counter.getState().increment();
counter.getState().count; // 1Exports
| Export | Description |
| -------------------------------- | ------------------------------------------------ |
| createStore(creator, options?) | Create a store with co-located state and actions |
Types
StoreApi<T>, StateCreator<T>, SetStateFn<T>, GetStateFn<T>, Listener<T>, SetFn<T>, Middleware<T>, MiddlewareAPI<T>, StoreOptions<T>
Size
~0.5 KB gzipped (+ core)
