本文整理汇总了TypeScript中mobx.runInAction函数的典型用法代码示例。如果您正苦于以下问题:TypeScript runInAction函数的具体用法?TypeScript runInAction怎么用?TypeScript runInAction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了runInAction函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: loadProfilesLogic
export async function loadProfilesLogic(
store: UserSettingsStore,
): Promise<void> {
const db = new UserSettingDatabase();
const profiles = (await db.color.toArray()).map(updateProfileToLatest);
// Read current theme.
const currentProfile = themeStore.savedTheme.colorProfile;
// check whether current theme is in saved profiles.
if (profiles.some(p => p.id === currentProfile.id)) {
runInAction(() => {
store.updateSavedProfiles(profiles);
store.setCurrentProfile(currentProfile);
});
return;
}
// if not the default one, discard its id.
runInAction(() => {
store.updateSavedProfiles(profiles);
store.setCurrentProfile({
...currentProfile,
id: null,
name: currentProfile.name || '?',
});
});
}
示例3: autorun
autorun(() => {
const hasVariable = chart.map.variableId && chart.vardata.variablesById[chart.map.variableId]
if (!hasVariable && chart.data.primaryVariable) {
const variableId = chart.data.primaryVariable.id
runInAction(() => chart.map.props.variableId = variableId)
}
})
示例4: refreshAsync
@mobx.action
async refreshAsync() {
let request = await fetch('/api/library');
let list = await request.json() as shared.IApiList;
let listEntries = list.map(listEntry => new mio.ListEntryViewModel(listEntry));
mobx.runInAction(() => this.entries = listEntries.sort((a, b) => a.key < b.key ? -1 : 1));
}
示例5: findWindowByWebContents
(
event: any,
state: {
modified: boolean;
projectFilePath: string;
undo: string | null;
redo: string | null;
}
) => {
const window = findWindowByWebContents(event.sender);
if (window) {
runInAction(() => {
window.state = {
modified: state.modified,
undo: state.undo,
redo: state.redo
};
if (isProjectEditor(window)) {
window.url =
PROJECT_WINDOW_URL +
PROJECT_FILE_PATH_PARAM +
encodeURIComponent(state.projectFilePath);
}
});
}
}
示例6: runInAction
.end((err: any, res: request.Response) => {
const data = res.body.data as VpApi.GetCommitsResponse;
runInAction(() => {
loadingStore.setLoading(false);
appStore.setDisplayUpdateNotice(false);
if (err) {
commitsTableStore.reset();
servicePanelStore.setMessage(getErrorMessage(res, err));
} else {
navigationStore.activeQuery = navigationStore.query;
if (navigationStore.activeQuery !== '' && commitsTableStore.showVisualisation) {
commitsTableStore.toggleShowVisualisation(false);
}
commitsTableStore.setPages(data.pages.map(c => c + 1));
commitsTableStore.setCommitRows(data.commits.map(commit =>
new CommitRow(commit, indexOf(appStore.selectedCommits, commit) !== -1)
));
servicePanelStore.setMessage(null);
checkUpdate();
}
});
});
示例7: runInAction
createObject: (object: any) => {
if (object.type === "activity-log/session-start") {
runInAction(() => {
this.id = object.id;
this.message = object.message;
});
}
},
示例8: refreshAsync
@mobx.action
async refreshAsync() {
let request = await fetch(`/api/library/${encodeURIComponent(this._listEntry.providerName)}/${encodeURIComponent(this._listEntry.seriesTitle)}`);
let series = await request.json() as shared.IApiSeries;
mobx.runInAction(() => {
this.chapters = series.chapters.map(seriesChapter => new mio.SeriesChapterViewModel(this._listEntry, series, seriesChapter));
this.title = series.title;
});
}