當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。