本文整理匯總了TypeScript中@ephox/katamari.Futures類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Futures類的具體用法?TypeScript Futures怎麽用?TypeScript Futures使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Futures類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
const updatePositions = function (container, winY) {
const fixtures = IosViewport.findFixtures(container);
const updates = Arr.map(fixtures, function (fixture) {
return updateFixture(fixture, winY);
});
return Futures.par(updates);
};
示例2: function
const loadAll = function (urls: string[], success: Function, failure: Function) {
Futures.par(Arr.map(urls, loadF)).get(function (result) {
const parts = Arr.partition(result, function (r) {
return r.isValue();
});
if (parts.fail.length > 0) {
failure(parts.fail.map(unbox));
} else {
success(parts.pass.map(unbox));
}
});
};
示例3: resolve
const readBlobsAsDataUris = (items: File[]) => {
return Futures.mapM(items, (item: any) => {
return Future.nu((resolve) => {
const blob = item.getAsFile ? item.getAsFile() : item;
const reader = new window.FileReader();
reader.onload = () => {
resolve({
blob,
uri: reader.result
});
};
reader.readAsDataURL(blob);
});
});
};