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


TypeScript services.Session類代碼示例

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


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

示例1: it

 it('should fail for error response status', async () => {
   const serverSettings = getRequestHandler(500, {});
   const sessionModel = createSessionModel();
   const options = createSessionOptions(sessionModel, serverSettings);
   const sessionPromise = Session.startNew(options);
   await expectFailure(sessionPromise, '');
 });
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:7,代碼來源:session.spec.ts

示例2: it

 it('should be safe to call twice', () => {
   const session = Session.connectTo(defaultSession.model);
   session.dispose();
   expect(session.isDisposed).to.equal(true);
   session.dispose();
   expect(session.isDisposed).to.equal(true);
 });
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:7,代碼來源:isession.spec.ts

示例3: main

function main() {
  // Start a new session.
  let options: Session.IOptions = {
    kernelName: 'python',
    path: 'foo.ipynb'
  };
  let session: Session.ISession;

  log('Starting session');
  Session.startNew(options).then(s => {
    log('Session started');
    session = s;
    // Rename the session.
    return session.setPath('bar.ipynb');
  }).then(() => {
    log(`Session renamed to ${session.path}`);
    // Execute and handle replies on the kernel.
    let future = session.kernel.requestExecute({ code: 'a = 1' });
    future.onReply = (reply) => {
      log('Got execute reply');
    };
    return future.done;
  }).then(() => {
      log('Future is fulfilled');
      // Shut down the session.
      return session.shutdown();
  }).then(() => {
      log('Session shut down');
      log('Test Complete!');
  }).catch(err => {
    console.error(err);
    log('Test Failed! See the console output for details');
  });
}
開發者ID:7125messi,項目名稱:jupyterlab,代碼行數:34,代碼來源:index.ts

示例4: main

function main(): void {
  let path = 'dummy_path';
  let query: { [key: string]: string } = Object.create(null);

  window.location.search.substr(1).split('&').forEach(item => {
    let pair = item.split('=');
    if (pair[0]) {
      query[pair[0]] = pair[1];
    }
  });

  if (!query['path']) {
    Session.startNew({ path }).then(session => { startApp(session); });
    return;
  }

  Session.findByPath(query['path'])
    .then(model => { return Session.connectTo(model.id); })
    .then(session => { startApp(session); })
    .catch(error => {
      console.warn(`path="${query['path']}"`, error);
      Session.startNew({ path }).then(session => { startApp(session); });
    });
}
開發者ID:danielballan,項目名稱:jupyterlab,代碼行數:24,代碼來源:index.ts


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