UNPKG

mobx-keystone-mindreframer

Version:

A MobX powered state management solution based on data trees with first class support for Typescript, snapshots, patches and much more

15 lines (11 loc) 352 B
import { ActionCallArgumentSerializer, cannotSerialize } from "./core" export const dateSerializer: ActionCallArgumentSerializer<Date, number> = { id: "mobx-keystone/dateAsTimestamp", serialize(date) { if (!(date instanceof Date)) return cannotSerialize return +date }, deserialize(timestamp) { return new Date(timestamp) }, }