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

TypeScript core.actions类代码示例

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

本文整理汇总了TypeScript中@nteract/core.actions的典型用法代码示例。如果您正苦于以下问题:TypeScript actions类的具体用法?TypeScript actions怎么用?TypeScript actions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了actions类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: hot

    testScheduler.run(helpers => {
      const { hot, expectObservable } = helpers;

      const inputActions = {
        a: actionsModule.restartKernel({
          outputHandling: "Run All",
          kernelRef: "oldKernelRef"
        }),
        b: actionsModule.launchKernelSuccessful({
          kernel: "",
          kernelRef: newKernelRef,
          selectNextKernel: true
        })
      };

      const outputActions = {
        c: actionsModule.killKernel({
          restarting: true,
          kernelRef: "oldKernelRef"
        }),
        d: actionsModule.launchKernelByName({
          kernelSpecName: null,
          cwd: ".",
          kernelRef: newKernelRef,
          selectNextKernel: true
        }),
        e: actionsModule.restartKernelSuccessful({
          kernelRef: newKernelRef
        }),
        f: actionsModule.executeAllCells({})
      };

      const inputMarbles = "a---b---|";
      const outputMarbles = "(cd)(ef)|";

      const inputAction$ = hot(inputMarbles, inputActions);
      const outputAction$ = restartKernelEpic(
        inputAction$,
        { value: state },
        () => newKernelRef
      );

      expectObservable(outputAction$).toBe(outputMarbles, outputActions);
    });
开发者ID:kelleyblackmore,项目名称:nteract,代码行数:44,代码来源:kernel-lifecycle.spec.ts


示例2: map

 map(data =>
   actions.configLoaded({
     config: JSON.parse(data.toString())
   })
开发者ID:nteract,项目名称:nteract,代码行数:4,代码来源:config.ts


示例3: dispatchLoadConfig

export function dispatchLoadConfig(
  _ownProps: { contentRef: ContentRef },
  store: DesktopStore
) {
  store.dispatch(actions.loadConfig());
}
开发者ID:nteract,项目名称:nteract,代码行数:6,代码来源:menu.ts


示例4:

 .catch(e => store.dispatch(actions.coreError(e)));
开发者ID:nteract,项目名称:nteract,代码行数:1,代码来源:menu.ts


示例5: dispatchDeleteCell

export function dispatchDeleteCell(
  ownProps: { contentRef: ContentRef },
  store: DesktopStore
) {
  store.dispatch(actions.deleteCell({ contentRef: ownProps.contentRef }));
}
开发者ID:nteract,项目名称:nteract,代码行数:6,代码来源:menu.ts


示例6: dispatchPasteCell

export function dispatchPasteCell(
  ownProps: { contentRef: ContentRef },
  store: DesktopStore
) {
  store.dispatch(actions.pasteCell(ownProps));
}
开发者ID:nteract,项目名称:nteract,代码行数:6,代码来源:menu.ts


示例7: dispatchClearAll

export function dispatchClearAll(
  ownProps: { contentRef: ContentRef },
  store: DesktopStore
) {
  store.dispatch(actions.clearAllOutputs(ownProps));
}
开发者ID:nteract,项目名称:nteract,代码行数:6,代码来源:menu.ts


示例8: dispatchRunAll

export function dispatchRunAll(
  ownProps: { contentRef: ContentRef },
  store: DesktopStore
) {
  store.dispatch(actions.executeAllCells(ownProps));
}
开发者ID:nteract,项目名称:nteract,代码行数:6,代码来源:menu.ts


示例9: dispatchPublishGist

export function dispatchPublishGist(
  ownProps: { contentRef: ContentRef },
  store: DesktopStore,
  _event: Event
) {
  const state = store.getState();
  const githubToken = state.app.get("githubToken");

  // The simple case -- we have a token and can publish
  if (githubToken != null) {
    store.dispatch(actions.publishGist(ownProps));
    return;
  }

  // If the Github Token isn't set, use our oauth server to acquire a token

  // Because the remote object from Electron main <--> renderer can be "cleaned up"
  // we re-require electron here and get the remote object
  const remote = require("electron").remote;

  // Create our oauth window
  const win = new remote.BrowserWindow({
    show: false,
    webPreferences: { zoomFactor: 0.75 }
  });

  // TODO: This needs to be moved to an epic
  win.webContents.on("dom-ready", () => {
    // When we're at our callback code page, keep the page hidden
    if (win.webContents.getURL().indexOf("callback?code=") !== -1) {
      // Extract the text content
      win.webContents.executeJavaScript(
        "require('electron').ipcRenderer.send('auth', document.body.textContent);"
      );
      remote.ipcMain.on("auth", (_event: Event, auth: string) => {
        try {
          const accessToken = JSON.parse(auth).access_token;
          store.dispatch(actions.setGithubToken(accessToken));

          const notificationSystem = selectors.notificationSystem(state);

          notificationSystem.addNotification({
            title: "Authenticated",
            message: "🔒",
            level: "info"
          });

          // We are now authenticated and can finally publish
          store.dispatch(actions.publishGist(ownProps));
        } catch (e) {
          store.dispatch(actions.coreError(e));
        } finally {
          win.close();
        }
      });
    } else {
      win.show();
    }
  });
  win.loadURL("https://oauth.nteract.io/github");
}
开发者ID:nteract,项目名称:nteract,代码行数:61,代码来源:menu.ts


示例10: mergeMap

    mergeMap((action: actions.PublishGist) => {
      const state = state$.value;

      const contentRef = action.payload.contentRef;
      if (!contentRef) {
        return empty();
      }

      // TODO: Switch GitHub publishing actions to content refs
      const content = selectors.content(state, { contentRef });
      // NOTE: This could save by having selectors for each model type
      //       have toDisk() selectors
      if (!content || content.type !== "notebook") {
        return empty();
      }

      const filepath = content.filepath;
      const notificationSystem = selectors.notificationSystem(state);

      const model = content.model;

      const notebookString = selectors.notebook.asString(model);
      const gistId = selectors.notebook.gistId(model);

      // Allow falling back on the GITHUB_TOKEN environment variable
      const githubToken = state.app.get("githubToken");

      if (githubToken == null) {
        return of(
          actions.coreError(
            new Error("need a github token in order to publish")
          )
        );
      }

      if (gistId && typeof gistId !== "string") {
        return of(
          actions.coreError(new Error("gist id in notebook is not a string"))
        );
      }

      // We are updating, so we require both a gist Id and a github token
      // If this doesn't happen to be our originally gisted notebook,
      // we should likely fork and publish
      //
      // TODO: Check to see if the token matches that of the username listed
      //       in the notebook itself
      if (gistId) {
        notificationSystem.addNotification({
          title: "Updating Gist...",
          message: "💖📓💖",
          dismissible: true,
          position: "tr",
          level: "success"
        });
      } else {
        notificationSystem.addNotification({
          title: "Publishing a New Gist...",
          message: "✨📓✨",
          dismissible: true,
          position: "tr",
          level: "success"
        });
      }

      const filename = filepath ? path.parse(filepath).base : "Untitled.ipynb";
      const files: GithubFiles = {
        [filename]: { content: notebookString }
      };

      return publishGist(
        { files, description: filename, public: false },
        githubToken,
        gistId
      ).pipe(
        mergeMap(xhr => {
          const notificationSystem = selectors.notificationSystem(state$.value);

          const { id, login } = xhr.response;

          // NOTE: One day we need to make this part of our proper store
          //       instead of hidden side effects
          notificationSystem.addNotification({
            title: "Gist uploaded",
            message: "📓 📢",
            dismissible: true,
            position: "tr",
            level: "success",
            action: {
              label: "Open Gist",
              callback() {
                shell.openExternal(`https://nbviewer.jupyter.org/${id}`);
              }
            }
          });

          // TODO: Turn this into one action that does both, even if its
          // sometimes a no-op
          return of(
            actions.overwriteMetadataField({
//.........这里部分代码省略.........
开发者ID:nteract,项目名称:nteract,代码行数:101,代码来源:github-publish.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript core.selectors类代码示例发布时间:2022-05-28
下一篇:
TypeScript core.makeNotebookContentRecord函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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