@umpire/tanstack-store
@umpire/tanstack-store is the TanStack Store integration for Umpire. TanStack Store notifies subscribers on change but doesn’t carry previous state, so this adapter tracks it on your behalf. Everything else — select(), conditions, the UmpireStore surface — works the same as @umpire/zustand.
Install
Section titled “Install”yarn add @umpire/core @umpire/tanstack-store @tanstack/storefromTanStackStore()
Section titled “fromTanStackStore()”function fromTanStackStore< S, F extends Record<string, FieldDef>, C extends Record<string, unknown> = Record<string, unknown>,>( ump: Umpire<F, C>, store: { state: S subscribe(listener: () => void): () => void }, options: FromStoreOptions<S, F, C>,): UmpireStore<F>Example
Section titled “Example”import { createStore } from '@tanstack/store'import { enabledWhen, umpire } from '@umpire/core'import { fromTanStackStore } from '@umpire/tanstack-store'
const ump = umpire({ fields: { password: {}, confirmPassword: { default: '' }, }, rules: [ enabledWhen('confirmPassword', (values) => { return (values.password as string)?.length > 0 }), ],})
const store = createStore({ password: '', confirmPassword: '',})
const umpStore = fromTanStackStore(ump, store, { select: (state) => ({ password: state.password, confirmPassword: state.confirmPassword, }),})select()is still the aggregation point for cross-slice state.- The returned surface matches
@umpire/store. - Zustand users should use
@umpire/zustandinstead.