本文整理汇总了TypeScript中mobx.ObservableMap.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ObservableMap.get方法的具体用法?TypeScript ObservableMap.get怎么用?TypeScript ObservableMap.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mobx.ObservableMap
的用法示例。
在下文中一共展示了ObservableMap.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('reacts to changing values', () => {
const remath = new Remath();
let view: ObservableMap<string> = observable.map<string>();
autorun(() => {
renderCells(remath, view);
});
// add a
runInAction(() => {
const a = remath.addCell({
symbol: 'a',
formula: '= 10'
});
});
expect(view.get('a')).to.equal('sym:a,formula:10,val:10,disp:10');
// add b
runInAction(() => {
const b = remath.addCell({
symbol: 'b',
formula: '= a + 10'
});
});
expect(view.get('a')).to.equal('sym:a,formula:10,val:10,disp:10');
expect(view.get('b')).to.equal('sym:b,formula:a + 10,val:20,disp:20');
// change a
runInAction(() => {
remath.find('a').setFormula('= 20');
});
expect(view.get('a')).to.equal('sym:a,formula:20,val:20,disp:20');
expect(view.get('b')).to.equal('sym:b,formula:a + 10,val:30,disp:30');
});
示例2: 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;
}
示例3:
const renderA = sinon.spy(() => {
view = map.get('a');
});