當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript localforage.setItem函數代碼示例

本文整理匯總了TypeScript中localforage.setItem函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript setItem函數的具體用法?TypeScript setItem怎麽用?TypeScript setItem使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了setItem函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

 handler: data => {
   localforage.setItem("defaultSearch", data.term).then((value) => {
     this.defaultSearch = value;
   }).catch((err) => {
     console.log(err);
   })
 }
開發者ID:jgw96,項目名稱:Soundel,代碼行數:7,代碼來源:settings.ts

示例2:

 const runTestScenario = () =>
     localforage
         .setItem('UserProfile', {
             UserName: 'user1',
             Password: '12345',
         })
         .then(() =>
             localforage.setItem('UserProfile', {
                 UserName: 'user1',
                 Password: '67890',
             }),
         )
         // this should not notify the subscribers
         .then(() =>
             localforage.setItem('UserProfile', {
                 UserName: 'user1',
                 Password: '67890',
             }),
         )
         .then(() => localforage.setItem('test1', 'value1'))
         .then(() => localforage.setItem('test2', 'value2'))
         .then(() => localforage.setItem('test2', 'value2b'))
         // this should not notify subscribers w/ changeDetection
         .then(() => localforage.setItem('test2', 'value2b'))
         .then(() => localforage.setItem('test3', 'value3'))
         .then(() => localforage.removeItem('test3'))
         .then(() => localforage.removeItem('test3'))
         .then(() => localforage.clear())
         // this should not notify subscribers w/ changeDetection
         .then(() => localforage.clear());
開發者ID:localForage,項目名稱:localForage-observable,代碼行數:30,代碼來源:observing-keys.spec.ts

示例3:

 .then(function() {
     // this should not notify the subscribers
     return localforage.setItem('UserProfile', {
         UserName: 'user1',
         Password: '67890',
     });
 })
開發者ID:localForage,項目名稱:localForage-observable,代碼行數:7,代碼來源:getItemObservable.spec.ts

示例4:

 .subscribe(updated => {
   localforage
     .setItem('currentUser', updated)
     .then(() => {
       observer.next(updated);
       observer.complete();
     });
 });
開發者ID:hellsan631,項目名稱:the-league,代碼行數:8,代碼來源:member.service.ts

示例5: setItem

function setItem(context: Context, key: string, value: any) {
  const { cache } = context.getState();
  if (!cache) {
    throw new Error(`Can't set item "${key}" before loading storage`);
  }

  const { projectId, items } = cache;
  const newItems = { ...items, [key]: value };
  context.setState({ cache: { projectId, items: newItems } });
  localForage.setItem(getProjectKey(projectId), newItems);
}
開發者ID:skidding,項目名稱:cosmos,代碼行數:11,代碼來源:index.ts

示例6:

 const runTestScenario = () =>
     localforage
         .setItem('test1', 'value1')
         .then(() => localforage.setItem('test2', 'value2'))
         .then(() => localforage.setItem('test2', 'value2b'))
         .then(() => localforage.setItem('test2', 'value2b'))
         .then(() => localforage.setItem('test3', 'value3'))
         .then(() => localforage.removeItem('test3'))
         .then(() => localforage.removeItem('test3'))
         .then(() => localforage.clear())
         .then(() => localforage.clear());
開發者ID:localForage,項目名稱:localForage-observable,代碼行數:11,代碼來源:main.spec.ts

示例7: setState

 static async setState(userId: string, state: State): Promise<void> {
     await localForage.setItem(LocalStore.getKey(userId), state);
 }
開發者ID:winken168,項目名稱:Hitchhiker,代碼行數:3,代碼來源:local_store.ts


注:本文中的localforage.setItem函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。