mirror of https://gitee.com/cf-fz/WebCAD.git
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.
97 lines
1.6 KiB
97 lines
1.6 KiB
7 years ago
|
import { autorun } from 'mobx';
|
||
7 years ago
|
import * as mst from 'mobx-state-tree';
|
||
7 years ago
|
|
||
7 years ago
|
import { EntityData, IEntityData, LineData } from './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()
|
||
7 years ago
|
|
||
|
|
||
|
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);
|
||
|
}
|
||
|
|
||
7 years ago
|
function add(a, b)
|
||
|
{
|
||
|
return a + b;
|
||
|
}
|
||
|
|
||
|
//Remove Path
|
||
|
{
|
||
|
|
||
|
const L = mst.types.model(
|
||
|
"Test",
|
||
|
{
|
||
|
lst: mst.types.array(mst.types.number)
|
||
7 years ago
|
})
|
||
|
.actions(self =>{
|
||
|
return{
|
||
|
remove(a)
|
||
|
{
|
||
|
this.lst.remove(a)
|
||
|
}
|
||
7 years ago
|
}
|
||
7 years ago
|
})
|
||
7 years ago
|
|
||
|
let l = L.create({ lst: [1, 2, 3] })
|
||
7 years ago
|
mst.onPatch(l, (p,rp) =>
|
||
7 years ago
|
{
|
||
7 years ago
|
console.log(p);
|
||
7 years ago
|
})
|
||
7 years ago
|
l.remove(3);
|
||
7 years ago
|
}
|