You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WebCAD/__test__/EntityData.quo.ts

99 lines
1.7 KiB

import * as console from 'console';
7 years ago
import { autorun } from 'mobx';
import * as mst from 'mobx-state-tree';
7 years ago
import { EntityData, IEntityData, LineData } from '../src/DatabaseServices/EntityData';
7 years ago
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);
7 years ago
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);
}