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

TypeScript core.selectors类代码示例

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

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



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

示例1: cwdKernelFallback

      index => {
        if (index === 0) {
          const state = store.getState();
          const oldKernelRef = selectors.kernelRefByContentRef(state, ownProps);
          if (!oldKernelRef) {
            console.error("kernel not available for relaunch");
            return;
          }
          const kernel = selectors.kernel(state, { kernelRef: oldKernelRef });
          if (!kernel) {
            console.error("kernel not available for relaunch");
            return;
          }

          const cwd = filepath
            ? path.dirname(path.resolve(filepath))
            : cwdKernelFallback();

          // Create a brand new kernel
          const kernelRef = createKernelRef();

          store.dispatch(
            actions.launchKernelByName({
              kernelSpecName: kernel.kernelSpecName,
              cwd,
              selectNextKernel: true,
              kernelRef,
              contentRef: ownProps.contentRef
            })
          );
        }
        resolve();
      }
开发者ID:nteract,项目名称:nteract,代码行数:33,代码来源:menu.ts


示例2: mergeMap

    mergeMap(action => {
      const state = state$.value;
      const contentRef = action.payload.contentRef;

      const content = selectors.content(state, { contentRef });
      if (!content) {
        return of(
          actions.saveFailed({
            contentRef: action.payload.contentRef,
            error: new Error("no notebook loaded to save")
          })
        );
      }
      const model = content.model;

      if (!model || model.type !== "notebook") {
        return of(
          actions.saveFailed({
            contentRef: action.payload.contentRef,
            error: new Error("no notebook loaded to save")
          })
        );
      }

      const filepath = content.filepath;
      const appVersion = selectors.appVersion(state);
      const notebook = stringifyNotebook(
        toJS(
          model.notebook.setIn(["metadata", "nteract", "version"], appVersion)
        )
      );
      return writeFileObservable(filepath, notebook).pipe(
        map(() => {
          if (process.platform !== "darwin") {
            const notificationSystem = selectors.notificationSystem(
              state$.value
            );
            notificationSystem.addNotification({
              autoDismiss: 2,
              level: "success",
              title: "Save successful!"
            });
          }
          return actions.saveFulfilled({
            contentRef: action.payload.contentRef,
            model: {
              last_modified: new Date()
            }
          });
        }),
        catchError((error: Error) =>
          of(
            actions.saveFailed({
              contentRef: action.payload.contentRef,
              error
            })
          )
        )
      );
    })
开发者ID:nteract,项目名称:nteract,代码行数:60,代码来源:saving.ts


示例3: onBeforeUnloadOrReload

export function onBeforeUnloadOrReload(
  contentRef: ContentRef,
  store: DesktopStore,
  reloading: boolean
) {
  const state = store.getState();
  const model = selectors.model(state, { contentRef });

  if (!model || model.type !== "notebook") {
    // No model on the page, don't block them
    return;
  }

  const closingState = state.desktopNotebook.closingState;
  if (closingState === DESKTOP_NOTEBOOK_CLOSING_NOT_STARTED) {
    // Dispatch asynchronously since returning ASAP is imperative for canceling close/unload.
    // See https://github.com/electron/electron/issues/12668
    setTimeout(
      () => store.dispatch(closeNotebook({ contentRef, reloading })),
      0
    );
  }

  if (closingState !== DESKTOP_NOTEBOOK_CLOSING_READY_TO_CLOSE) {
    return false;
  }
}
开发者ID:nteract,项目名称:nteract,代码行数:27,代码来源:global-events.ts


示例4: dispatchNewKernel

export function dispatchNewKernel(
  ownProps: { contentRef: ContentRef },
  store: DesktopStore,
  _evt: Event,
  kernelSpec: KernelSpec
) {
  const state = store.getState();
  const filepath = selectors.filepath(state, ownProps);
  const cwd =
    filepath !== null
      ? path.dirname(path.resolve(filepath))
      : cwdKernelFallback();

  // Create a brand new kernel
  const kernelRef = createKernelRef();

  store.dispatch(
    actions.launchKernel({
      kernelSpec,
      cwd,
      selectNextKernel: true,
      kernelRef,
      contentRef: ownProps.contentRef
    })
  );
}
开发者ID:nteract,项目名称:nteract,代码行数:26,代码来源:menu.ts


示例5: mergeMap

    mergeMap((action: actions.FetchContentFulfilled) => {
      const contentRef = action.payload.contentRef;

      const content = selectors.content(state$.value, { contentRef });

      if (
        !content ||
        content.type !== "notebook" ||
        content.model.type !== "notebook"
      ) {
        // This epic only handles notebook content
        return empty();
      }

      const filepath = content.filepath;
      const notebook = content.model.notebook;

      const { cwd, kernelSpecName } = extractNewKernel(filepath, notebook);

      return of(
        actions.launchKernelByName({
          kernelSpecName,
          cwd,
          kernelRef: action.payload.kernelRef,
          selectNextKernel: true,
          contentRef: action.payload.contentRef
        })
      );
    })
开发者ID:nteract,项目名称:nteract,代码行数:29,代码来源:loading.ts


示例6: storeToPDF

export function storeToPDF(
  ownProps: { contentRef: ContentRef },
  store: DesktopStore
) {
  const state = store.getState();
  const notebookName = selectors.filepath(state, ownProps);
  const notificationSystem = state.app.get("notificationSystem");
  if (notebookName === null) {
    notificationSystem.addNotification({
      title: "File has not been saved!",
      message: `Click the button below to save the notebook so that it can be
       exported as a PDF.`,
      dismissible: true,
      position: "tr",
      level: "warning",
      action: {
        label: "Save As",
        callback() {
          triggerSaveAsPDF(ownProps, store);
        }
      }
    });
  } else {
    const basename = path.basename(notebookName, ".ipynb");
    const basepath = path.join(path.dirname(notebookName), basename);
    exportPDF(ownProps, store, basepath, notificationSystem);
  }
}
开发者ID:nteract,项目名称:nteract,代码行数:28,代码来源:menu.ts


示例7: mergeMap

 mergeMap((state: AppState) => {
   const content = selectors.content(state, { contentRef });
   if (content) {
     return of(content);
   } else {
     return empty();
   }
 })
开发者ID:nteract,项目名称:nteract,代码行数:8,代码来源:native-window.ts


示例8:

 (state: AppState, kernelRef: KernelRef) => {
   const kernel = selectors.kernel(state, { kernelRef });
   if (!kernel) {
     return "not connected";
   } else {
     return kernel.status;
   }
 }
开发者ID:nteract,项目名称:nteract,代码行数:8,代码来源:native-window.ts


示例9: dispatchKillKernel

export function dispatchKillKernel(
  ownProps: { contentRef: ContentRef },
  store: DesktopStore
) {
  const state = store.getState();
  const kernelRef = selectors.kernelRefByContentRef(state, ownProps);
  if (!kernelRef) {
    store.dispatch(actions.coreError(new Error("kernel not set")));
    return;
  }

  store.dispatch(actions.killKernel({ restarting: false, kernelRef }));
}
开发者ID:nteract,项目名称:nteract,代码行数:13,代码来源:menu.ts


示例10: dispatchSave

export function dispatchSave(
  ownProps: { contentRef: ContentRef },
  store: DesktopStore
) {
  const state = store.getState();

  const filepath = selectors.filepath(state, ownProps);

  if (filepath === null || filepath === "") {
    triggerSaveAs(ownProps, store);
  } else {
    store.dispatch(actions.save(ownProps));
  }
}
开发者ID:nteract,项目名称:nteract,代码行数:14,代码来源:menu.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript core.state类代码示例发布时间:2022-05-28
下一篇:
TypeScript core.actions类代码示例发布时间: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