Main state adapter that manages both backtest and live state storage.
Features:
constructor();
enable: (() => (...args: any[]) => any) & ISingleshotClearable<() => (...args: any[]) => any>
Enables state storage by subscribing to signal lifecycle events. Clears memoized instances in StateBacktest and StateLive when a signal is cancelled or closed, preventing stale instances from accumulating. Uses singleshot to ensure one-time subscription.
disable: () => void
Disables state storage by unsubscribing from signal lifecycle events. Safe to call multiple times.
getState: <Value extends object = object>(dto: { signalId: string; bucketName: string; initialValue: object; backtest: boolean; }) => Promise<Value>
Read the current state value for a signal. Routes to StateBacktest or StateLive based on dto.backtest.
setState: <Value extends object = object>(dispatch: Value | Dispatch<Value>, dto: { signalId: string; bucketName: string; initialValue: object; backtest: boolean; }) => Promise<Value>
Update the state value for a signal. Routes to StateBacktest or StateLive based on dto.backtest.