當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript apputils.IClientSession類代碼示例

本文整理匯總了TypeScript中@jupyterlab/apputils.IClientSession的典型用法代碼示例。如果您正苦於以下問題:TypeScript IClientSession類的具體用法?TypeScript IClientSession怎麽用?TypeScript IClientSession使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了IClientSession類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: KernelStatus

  activate: (
    app: JupyterLab,
    statusBar: IStatusBar,
    notebookTracker: INotebookTracker,
    consoleTracker: IConsoleTracker
  ) => {
    // When the status item is clicked, launch the kernel
    // selection dialog for the current session.
    let currentSession: IClientSession | null = null;
    const changeKernel = () => {
      if (!currentSession) {
        return;
      }
      currentSession.selectKernel();
    };

    // Create the status item.
    const item = new KernelStatus({
      onClick: changeKernel
    });

    // When the title of the active widget changes, update the label
    // of the hover text.
    const onTitleChanged = (title: Title<Widget>) => {
      item.model!.activityName = title.label;
    };

    // Keep the session object on the status item up-to-date.
    app.shell.currentChanged.connect((shell, change) => {
      const { oldValue, newValue } = change;

      // Clean up after the old value if it exists,
      // listen for changes to the title of the activity
      if (oldValue) {
        oldValue.title.changed.disconnect(onTitleChanged);
      }
      if (newValue) {
        newValue.title.changed.connect(onTitleChanged);
      }

      // Grab the session off of the current widget, if it exists.
      if (newValue && consoleTracker.has(newValue)) {
        currentSession = (newValue as ConsolePanel).session;
      } else if (newValue && notebookTracker.has(newValue)) {
        currentSession = (newValue as NotebookPanel).session;
      } else {
        currentSession = null;
      }
      item.model!.session = currentSession;
    });

    statusBar.registerStatusItem(
      '@jupyterlab/statusbar-extension:kernel-status',
      {
        item,
        align: 'left',
        rank: 1,
        isActive: () => {
          const current = app.shell.currentWidget;
          return (
            current &&
            (notebookTracker.has(current) || consoleTracker.has(current))
          );
        }
      }
    );
  }
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:67,代碼來源:index.ts

示例2:

 const changeKernel = () => {
   if (!currentSession) {
     return;
   }
   currentSession.selectKernel();
 };
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:6,代碼來源:index.ts

示例3: async

 const changeKernel = async () => {
   if (!currentSession) {
     return;
   }
   await currentSession.selectKernel();
 };
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:6,代碼來源:index.ts


注:本文中的@jupyterlab/apputils.IClientSession類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。