/*! * Copyright 2018 acrazing . All rights reserved. * @since 2018-06-27 00:25:38 */ /** * define a custom stringify/parse function for a field, it is useful for * builtin objects, just like Date, TypedArray, etc. * * @example * * // this example shows how to format a date to timestamp, * // and load it from serialized string, * // if the date is invalid, will not persist it. * class SomeStore { * @format( * (timestamp) => new Date(timestamp), * (date) => date ? +date : void 0, * ) * dateField = new Date() * } * * @param deserializer - the function to parse the serialized data to * custom object, the first argument is the data serialized by * `serializer`, and the second is the current value of the field. * @param serializer - the function to serialize the object to pure js * object or any else could be stringify safely by `JSON.stringify`. */ export declare function format(deserializer: (persistedValue: O, currentValue: I) => I, serializer?: (value: I) => O): PropertyDecorator; /** * The short hand for format date to ISO string * * @example * * class FooStore { * @date * dateField = new Date() * } */ export declare const date: PropertyDecorator; export interface RegExpStore { flags: string; source: string; } /** * the short hand for format RegExp */ export declare const regexp: PropertyDecorator; declare function _ignore(target: any, propertyKey: string): void; /** * ignore the field, which means: if serialize the current store, it will * be omitted, and if the previous version does not omit it, will also * be omitted when call `parseStore`. * * Note: if set current runtime as ssr, will do nothing. * * @example * * class FooStore { * @ignore * bigTable = observable.map() * } * * @param target * @param propertyKey */ declare function ignore(target: any, propertyKey: string): void; declare namespace ignore { var ssr: typeof _ignore; var ssrOnly: (target: any, propertyKey: string) => void; } export { ignore }; /** * set the version of the field, if the persisted data's version does not * equal to the current version, it will be omitted. * * @example * * class FooStore { * // this means the current version of users struct is 1, if * // your users's struct updated with breaking changes, you may need * // to update the 1 to 2 to avoid loading the previous version's * // users from localStorage. * @version(1) * users = observable.map() * } * * @param value - the version number, this should be different from all the * old version when update it, a best practice is use q increment number. */ export declare function version(value: number | string): (target: any, key?: string) => void;