import { SetStateSymbol } from '../const' import type { OrchModel } from '../model' export function reducer( model: OrchModel, fn: (state: Readonly, ...params: P) => S, ) { return (...params: P) => { const currentState = model.getState() const newState = fn(currentState, ...params) if (newState !== currentState) { model[SetStateSymbol](newState) } } }