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


TypeScript StateDB.save方法代碼示例

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


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

示例1: it

      it('should restore the widgets in a tracker', done => {
        let tracker = new InstanceTracker<Widget>({
          namespace: 'foo-widget',
          shell: new ApplicationShell()
        });
        let registry = new CommandRegistry();
        let state = new StateDB({ namespace: NAMESPACE });
        let ready = new PromiseDelegate<void>();
        let restorer = new LayoutRestorer({
          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:charnpreetsingh185,項目名稱:jupyterlab,代碼行數:30,代碼來源:layoutrestorer.spec.ts

示例2: it

 it('should enforce the maximum length of a stored item', done => {
   let db = new StateDB({ namespace: 'test' });
   let key = 'test-key';
   let data = { a: (new Array<string>(db.maxLength)).join('A') };
   db.save(key, data)
     .then(() => { done('maxLength promise should have rejected'); })
     .catch(() => { done(); });
 });
開發者ID:charnpreetsingh185,項目名稱:jupyterlab,代碼行數:8,代碼來源:statedb.spec.ts

示例3:

 let save = () => state.save(key, { version });
開發者ID:charnpreetsingh185,項目名稱:jupyterlab,代碼行數:1,代碼來源:index.ts

示例4:

 .then(() => db2.save('baz', { qux: null }))
開發者ID:charnpreetsingh185,項目名稱:jupyterlab,代碼行數:1,代碼來源:statedb.spec.ts


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