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


TypeScript services.utils.PromiseDelegate類代碼示例

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


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

示例1: it

      it('should restore the widgets in a tracker', done => {
        let tracker = new InstanceTracker<Widget>({ namespace: 'foo-widget' });
        let registry = new CommandRegistry();
        let state = new StateDB({ namespace: NAMESPACE });
        let ready = new utils.PromiseDelegate<void>();
        let restorer = new InstanceRestorer({
          first: ready.promise, registry, state
        });
        let called = false;
        let key = `${tracker.namespace}:${tracker.namespace}`;

        registry.addCommand(tracker.namespace, {
          execute: () => { called = true; }
        });
        state.save(key, { data: null }).then(() => {
          return restorer.restore(tracker, {
            args: () => null,
            name: () => tracker.namespace,
            command: tracker.namespace
          });
        }).catch(done);
        ready.resolve(void 0);
        restorer.restored.then(() => { expect(called).to.be(true); })
          .then(() => state.remove(key))
          .then(() => { done(); })
          .catch(done);
      });
開發者ID:Carreau,項目名稱:jupyterlab,代碼行數:27,代碼來源:instancerestorer.spec.ts

示例2: it

 it('should add a widget to be tracked by the restorer', done => {
   let ready = new utils.PromiseDelegate<void>();
   let restorer = new LayoutRestorer({
     first: ready.promise,
     registry: new CommandRegistry(),
     state: new StateDB({ namespace: NAMESPACE })
   });
   let currentWidget = new Widget();
   let mode: DockPanel.Mode = 'single-document';
   let dehydrated: ApplicationShell.ILayout = {
     mainArea: { currentWidget, dock: null, mode },
     leftArea: { collapsed: true, currentWidget: null, widgets: null },
     rightArea: { collapsed: true, currentWidget: null, widgets: null }
   };
   restorer.add(currentWidget, 'test-one');
   ready.resolve(void 0);
   restorer.restored.then(() => restorer.save(dehydrated))
     .then(() => restorer.fetch())
     .then(layout => {
       expect(layout.mainArea.currentWidget).to.be(currentWidget);
       expect(layout.mainArea.mode).to.be(mode);
       done();
     }).catch(done);
 });
開發者ID:faricacarroll,項目名稱:jupyterlab,代碼行數:24,代碼來源:layoutrestorer.spec.ts


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