当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript mobx.runInAction函数代码示例

本文整理汇总了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');
    });
开发者ID:trevorhanus,项目名称:reMath,代码行数:33,代码来源:Integration_1.test.ts

示例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 || '?',
    });
  });
}
开发者ID:uhyo,项目名称:jinrou,代码行数:25,代码来源:index.ts

示例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)
     }
 })
开发者ID:OurWorldInData,项目名称:owid-grapher,代码行数:7,代码来源:MapData.ts

示例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));
 }
开发者ID:Deathspike,项目名称:mangarack,代码行数:7,代码来源:ListViewModel.ts

示例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);
                }
            });
        }
    }
开发者ID:eez-open,项目名称:studio,代码行数:27,代码来源:window.ts

示例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();
        }
      });
    });
开发者ID:OddenCreative,项目名称:versionpress,代码行数:25,代码来源:commits.ts

示例7: runInAction

 createObject: (object: any) => {
     if (object.type === "activity-log/session-start") {
         runInAction(() => {
             this.id = object.id;
             this.message = object.message;
         });
     }
 },
开发者ID:eez-open,项目名称:studio,代码行数:8,代码来源:activity-log.ts

示例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;
   });
 }
开发者ID:Deathspike,项目名称:mangarack,代码行数:9,代码来源:SeriesViewModel.ts


注:本文中的mobx.runInAction函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。