Skip to content

@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.

Terminal window
yarn add @umpire/core @umpire/tanstack-store @tanstack/store
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>
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/zustand instead.