本文整理汇总了TypeScript中localforage.newObservable函数的典型用法代码示例。如果您正苦于以下问题:TypeScript newObservable函数的具体用法?TypeScript newObservable怎么用?TypeScript newObservable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了newObservable函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
.then(() => {
const setItemCallObservable = localforage.newObservable({
setItem: true,
});
setItemSubscription = setItemCallObservable.subscribe({
next: (change: LocalForageObservableChange) =>
setItemObservableLogs.push(formatChangeArg(change)),
error: err => {
errorCallCount++;
console.error('Found an error!', err);
},
complete: () => {
completeCallCount++;
},
});
const clearCallObservable = localforage.newObservable({
clear: true,
});
clearSubscription = clearCallObservable.subscribe({
next: (change: LocalForageObservableChange) =>
clearObservableLogs.push(formatChangeArg(change)),
error: err => {
errorCallCount++;
console.error('Found an error!', err);
},
complete: () => {
completeCallCount++;
},
});
});
示例2: it
it('should be able to create a new observable', function() {
m.chai.expect(() => localforage.newObservable()).to.not.throw();
m.chai
.expect(localforage.newObservable())
.to.have.property('subscribe')
.that.is.a('function');
});
示例3:
.then(() => {
const observable = localforage.newObservable();
subscription = observable.subscribe({
next: (change: LocalForageObservableChange) =>
observableLogs.push(formatChangeArg(change)),
error: err => {
errorCallCount++;
console.error('Found an error!', err);
},
complete: () => {
completeCallCount++;
},
});
});