当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript localforage.getItem方法代码示例

本文整理汇总了TypeScript中localforage.localforage.getItem方法的典型用法代码示例。如果您正苦于以下问题:TypeScript localforage.getItem方法的具体用法?TypeScript localforage.getItem怎么用?TypeScript localforage.getItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在localforage.localforage的用法示例。


在下文中一共展示了localforage.getItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: 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

示例2: 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

示例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


注:本文中的localforage.localforage.getItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。