當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。