本文整理汇总了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);
});
示例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(); });
});
示例3:
let save = () => state.save(key, { version });
示例4:
.then(() => db2.save('baz', { qux: null }))