本文整理匯總了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++;
},
});
});