当前位置: 首页>>代码示例>>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;未经允许,请勿转载。