import { Draft, produce } from 'immer' import { SetStateSymbol } from '../const' import type { OrchModel } from '../model' export function mutation( model: OrchModel, fn: (draft: Draft, ...params: P) => void, ) { return (...params: P) => { model[SetStateSymbol](produce((draft) => fn(draft, ...params))(model.getState())) } }