本文整理汇总了TypeScript中localforage.localforage类的典型用法代码示例。如果您正苦于以下问题:TypeScript localforage类的具体用法?TypeScript localforage怎么用?TypeScript localforage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了localforage类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: getZbook
async function getZbook(book : Book) : Promise<Database> {
let file = files[book.file];
if (!file) {
file = await localforage.getItem<BookFile>(book.file);
if (file) {
if (file.version !== book.file_version) {
// Update book in background.
fetchBinary(
book.url,
"Updating book " + book.name + "..."
).then(data => {
file.data = data;
// TODO: notify UI book has been updated
files[book.file] = file;
return localforage.setItem(book.file, file);
});
}
}
else {
file = {
version: book.file_version,
data: await fetchBinary(
book.url,
"Downloading book " + book.name + "..."
)
};
await localforage.setItem(book.file, file);
}
}
return new Database(inflate(file.data));
}
开发者ID:creationix,项目名称:gospel-viewer,代码行数:32,代码来源:app.ts
示例2: getCatalog
async function getCatalog() {
let language = await getLanguage();
let catalog = await localforage.getItem<Folder>("catalog");
if (catalog &&
platform == await localforage.getItem("platform") &&
language == await localforage.getItem("language")) {
updateCatalog(language); // check for update in background
return catalog; // But return cached value immediately
}
return await updateCatalog(language);
}
开发者ID:creationix,项目名称:gospel-viewer,代码行数:11,代码来源:app.ts
示例3: updateCatalog
async function updateCatalog(language) : Promise<Folder> {
let update = await fetchJson(
"http://tech.lds.org/glweb?action=catalog.query.modified&languageid=" +
language + "&platformid=" + platform + "&format=json",
"Checking for catalog updates..."
);
let version = update.version;
if (version == await localforage.getItem("version")) {
console.log("No catalog updates.");
return;
}
let result = await fetchJson(
"http://tech.lds.org/glweb?action=catalog.query&languageid=" +
language + "&platformid=" + platform + "&format=json",
"Downloading catalog..."
);
await localforage.setItem("catalog", result.catalog);
await localforage.setItem("version", version);
await localforage.setItem("language", language);
await localforage.setItem("platform", platform);
// TODO: use book.versions API to update any downloaded books.
return result.catalog;
}
开发者ID:creationix,项目名称:gospel-viewer,代码行数:23,代码来源:app.ts
示例4:
).then(data => {
file.data = data;
// TODO: notify UI book has been updated
files[book.file] = file;
return localforage.setItem(book.file, file);
});
开发者ID:creationix,项目名称:gospel-viewer,代码行数:6,代码来源:app.ts
注:本文中的localforage.localforage类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论