• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript mobx.runInAction函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript mobx.useStrict函数代码示例发布时间:2022-05-25
下一篇:
TypeScript mobx.reaction函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap