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


TypeScript AsyncStorage.setItem方法代码示例

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


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

示例1: finalizeLogIn

 /**
  * this should be called when the setup procedure has been successful
  * @param userId
  * @returns {*|Promise.<TResult>}
  */
 finalizeLogIn(userId) {
   // write to database that we are logged in.
   return AsyncStorage.setItem(LOGGED_IN_USER_ID_STORAGE_KEY, userId)
     .catch((err) => {
       LOGe.store("StoreManager: finalize login failed. ", err);
     })
 }
开发者ID:crownstone,项目名称:CrownstoneApp,代码行数:12,代码来源:storeManager.ts

示例2: setConsent

  public setConsent(consent: IDataPolicyConsent) {
    const serializedProgress = JSON.stringify(consent);

    return AsyncStorage.setItem(
      DataPolicyConsentStorage.getKey(),
      serializedProgress
    );
  }
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:8,代码来源:DataPolicyConsentStorage.ts

示例3: getCacheCurSize

  /**
   * return the current size of the cache
   * @return {Promise}
   */
  async getCacheCurSize() {
    let ret = await AsyncStorage.getItem(this.cacheCurSizeKey);
    if (!ret) {
      await AsyncStorage.setItem(this.cacheCurSizeKey, '0');
      ret = '0';
    }
    return Number(ret);

  }
开发者ID:lukethompson,项目名称:aws-amplify,代码行数:13,代码来源:AsyncStorageCache.ts

示例4: _setItem

  /**
   * put item into cache
   * @private
   * @param prefixedKey - the key of the item
   * @param itemData - the value of the item
   * @param itemSizeInBytes - the byte size of the item
   */
  async _setItem(prefixedKey, item) {
    // first try to update the current size of the cache.
    await this._increaseCurSizeInBytes(item.byteSize);

    // try to add the item into cache
    try {
      await AsyncStorage.setItem(prefixedKey, JSON.stringify(item));
    } catch (setItemErr) {
      // if some error happened, we need to rollback the current size
      await this._decreaseCurSizeInBytes(item.byteSize);
      logger.error(`Failed to set item ${setItemErr}`);
    }
  }
开发者ID:lukethompson,项目名称:aws-amplify,代码行数:20,代码来源:AsyncStorageCache.ts

示例5: setProgress

  public setProgress(id: string, progress: ISerializedProgress) {
    const serializedProgress = JSON.stringify(progress);

    return AsyncStorage.setItem(this.getKey(id), serializedProgress);
  }
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:5,代码来源:ProgressStorage.ts

示例6: set

 static set(key, value) {
   return AsyncStorage.setItem(key, JSON.stringify(value))
 }
开发者ID:Leonti,项目名称:receipts-mobile,代码行数:3,代码来源:Storage.ts

示例7:

 .then(() => {
   return AsyncStorage.setItem(this.userIdentificationStorageKey, "");
 })
开发者ID:crownstone,项目名称:CrownstoneApp,代码行数:3,代码来源:storeManager.ts

示例8: _refreshItem

  /**
   * update the visited time if item has been visited
   * @private
   * @param item - the item which need to be refreshed
   * @param prefixedKey - the key of the item
   * 
   * @return the refreshed item
   */
  async _refreshItem(item, prefixedKey) {
    item.visitedTime = getCurrTime();
    await AsyncStorage.setItem(prefixedKey, JSON.stringify(item));
    return item;

  }
开发者ID:lukethompson,项目名称:aws-amplify,代码行数:14,代码来源:AsyncStorageCache.ts

示例9: _increaseCurSizeInBytes

 /**
  * increase current size of the cache
  * @private
  * @param amount - the amount of the cache szie which need to be increased
  */
 async _increaseCurSizeInBytes(amount) {
   const curSize = await this.getCacheCurSize();
   await AsyncStorage.setItem(this.cacheCurSizeKey, (curSize + amount).toString());
 }
开发者ID:lukethompson,项目名称:aws-amplify,代码行数:9,代码来源:AsyncStorageCache.ts

示例10:

 snapshot => AsyncStorage.setItem(storageKey, JSON.stringify(snapshot)),
开发者ID:birkir,项目名称:kvikmyndr-app,代码行数:1,代码来源:index.ts


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