import { BasicUpdater, Updater } from "../../../fun/domains/updater/state"; import { AsyncState } from "../../state"; export type Synchronized = value & { sync: AsyncState; }; export const Synchronized = { Default: ( initialValue: value, sync?: AsyncState, ): Synchronized => ({ ...initialValue, sync: sync ?? AsyncState.Default.unloaded(), }), Updaters: { sync: ( _: BasicUpdater>, ): Updater> => Updater>((current) => ({ ...current, sync: _(current.sync), })), value: ( _: BasicUpdater, ): Updater> => Updater>((current) => ({ ...current, ..._(current), })), }, };