aboutsummaryrefslogtreecommitdiff
path: root/src/new_fields/RefField.ts
blob: 202c65f219f441344442bf05bc2eb0b1d5303997 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { serializable, primitive, alias } from "serializr";
import { Utils } from "../Utils";

export type FieldId = string;
export const HandleUpdate = Symbol("HandleUpdate");
export const Id = Symbol("Id");
export abstract class RefField {
    @serializable(alias("id", primitive()))
    private __id: FieldId;
    readonly [Id]: FieldId;

    constructor(id?: FieldId) {
        this.__id = id || Utils.GenerateGuid();
        this[Id] = this.__id;
    }

    protected [HandleUpdate]?(diff: any): void;
}