import * as console from 'console'; import { autorun } from 'mobx'; import * as mst from 'mobx-state-tree'; import { EntityData, IEntityData, LineData } from '../src/DatabaseServices/EntityData'; class E { m_Data: IEntityData; constructor() { this.initData(); autorun(() => { this.eraseT(this.m_Data.isErase); }) } initData() { this.m_Data = EntityData.create(); console.log("hello e"); } erase(isErase: boolean) { this.m_Data.setErase(isErase); } private eraseT(isErase: boolean) { console.log(isErase); } } class L extends E { constructor() { super() } initData() { this.m_Data = LineData.create(); console.log("hello l"); } } { let l = new L() let a: (typeof EntityData.SnapshotType) = mst.getSnapshot(l.m_Data); console.log(mst.getSnapshot(l.m_Data)); let snp = mst.getSnapshot(l.m_Data); l.erase(true); l.erase(true); l.erase(true); l.erase(true); l.erase(true); console.log(l.m_Data.isErase); mst.applySnapshot(l.m_Data, snp); console.log(l.m_Data.isErase); } function add(a, b) { return a + b; } //Remove Path { const L = mst.types.model( "Test", { lst: mst.types.array(mst.types.number) }) .actions(self => { return { remove(a) { this.lst.remove(a) } } }) let l = L.create({ lst: [1, 2, 3] }) mst.onPatch(l, (p, rp) => { console.log(p); }) l.remove(3); }