本文整理汇总了TypeScript中mobx.ObservableMap类的典型用法代码示例。如果您正苦于以下问题:TypeScript ObservableMap类的具体用法?TypeScript ObservableMap怎么用?TypeScript ObservableMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObservableMap类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('Adding variable whose formula references a non-existent symbol', () => {
const remath = new Remath();
let view: ObservableMap<string> = observable.map<string>();
const render = sinon.spy(() => {
renderCells(remath, view);
});
autorun(render);
// add a
const a = remath.addCell({
symbol: 'a',
formula: '= b + 10'
});
expect(render.callCount).to.equal(2);
expect(view.get('a')).to.equal('sym:a,formula:b + 10,val:NaN,disp:#REF?');
// add b = 30
runInAction(() => {
const b = remath.addCell({
symbol: 'b',
formula: '=30'
});
});
expect(view.get('b')).to.equal('sym:b,formula:30,val:30,disp:30');
expect(view.get('a')).to.equal('sym:a,formula:b + 10,val:40,disp:40');
});
示例2: it
it("builds the data for the volcano plot graph with the correct values", ()=>{
const map_genesets_selected_volcano = new ObservableMap<boolean>();
map_genesets_selected_volcano.set("AKT_UP.V1_DN", true);
const graphData = getVolcanoPlotData(genesets, map_genesets_selected_volcano);
assert.deepEqual(
graphData,
[{
x: 0.1986,
y: -(Math.log(genesets[0].representativePvalue)/Math.log(10)),
fill: "tomato"
},
{
x: 0.3945,
y: -(Math.log(genesets[1].representativePvalue)/Math.log(10)),
fill: "3786C2"
}]
);
});
示例3: find
find(symbolOrId: string): Cell {
let cell: Cell;
const probablyAnId = matchesIdFormat(symbolOrId);
if (probablyAnId) {
cell = this._cells.get(symbolOrId);
}
if (cell === undefined) { // maybe it is a symbol
const hash = hasher.getHash(symbolOrId);
cell = this._cells.get(hash) || null;
}
return cell;
}
示例4: addDependent
@action
addDependent(dependent: INode): void {
if (this.dependsOn(dependent)) {
this.throwCircRefError(`${dependent.id}'s formula references ${this.id}, but ${this.id} depends on ${dependent.id}`);
}
this._dependents.set(dependent.id, dependent);
}
示例5: addProvider
@action
addProvider(provider: INode): void {
if (this.providesFor(provider)) {
this.throwCircRefError(`${this.id}'s formula references ${provider.id}, but ${provider.id} depends on ${this.id}`);
}
this._providers.set(provider.id, provider);
}
示例6: removeCell
@action
removeCell(symbolOrId: string): Cell {
const cell = this.find(symbolOrId);
if (!cell) return;
// remove reference to this node in all dependent nodes
cell.dependents.forEach(node => {
node.removeProvider(cell);
});
// delete node from graph
this._cells.delete(cell.id);
return cell;
}
示例7: errors
@computed
get errors(): IError[] {
return this._errors.values();
}
示例8:
@action
__addError(error: IError): void {
this._errors.set(ErrorType[error.type], error);
}