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


TypeScript localforage.getItem函数代码示例

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


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

示例1: ionViewDidEnter

 ionViewDidEnter(): void {
   localforage.getItem("defaultSearch").then((value) => {
     console.log(value);
     if (value === null) {
       this.defaultSearch = "Tame Impala";
     }
     else {
       this.defaultSearch = value.toString();
     }
   })
 }
开发者ID:jgw96,项目名称:Soundel,代码行数:11,代码来源:settings.ts

示例2: return

 return Observable.create(observer => {
   localforage
     .getItem('currentUser')
     .then(member => {
       
       if (!member) {
         observer.next(false);
         return;
       }
       
       if (Object.keys(member).length > 1) {
         observer.next(member);
       } else {
         this.findById(member.id)
           .subscribe(
             memberFound => observer.next(memberFound),
             error => {
               this.logout()
                 .subscribe(() => {
                   observer.next(false);
                   observer.complete();
                 });
             }
           );
       }
           
       this.events.subscribe(event => {
         if (event.type === 'update' && event.data.id === member.id) {
           observer.next(event.data);
         }
       });
     })
     .catch(error => observer.error(error)); 
     
   this.events.subscribe(event => {
     if (event.type === 'auth') {
       observer.next(event.data);
     }
   });
   
   return () => {
     this.events.unsubscribe();
   }
 });
开发者ID:hellsan631,项目名称:the-league,代码行数:44,代码来源:member.service.ts

示例3:

 return Observable.create(observer => {
   localforage
     .getItem('currentUser')
     .then(member => {
       
       if (!member) {
         observer.error('No Member Found');
         return observer.complete();
       }
       
       this.updateById(member.id, data)
         .subscribe(updated => {
           localforage
             .setItem('currentUser', updated)
             .then(() => {
               observer.next(updated);
               observer.complete();
             });
         });
              
     })
     .catch(error => observer.error(error)); 
 });
开发者ID:hellsan631,项目名称:the-league,代码行数:23,代码来源:member.service.ts

示例4:

 loading.present().then(() => {
   localforage.getItem("defaultSearch").then((value) => {
     if (value === null) {
       this.musicService.getFirstTracks("Tame Impala").then((tracks) => {
         this.songs = tracks;
         console.log(tracks);
         SC.stream(`/tracks/${tracks[0].id}`).then((player) => {
           this.initSong = player;
         })
         loading.dismiss();
       })
     }
     else {
       this.musicService.getFirstTracks(value).then((tracks) => {
         console.log(tracks);
         SC.stream(`/tracks/${tracks[0].id}`).then((player) => {
           this.initSong = player;
         })
         this.songs = tracks;
         loading.dismiss();
       })
     }
   })
 });
开发者ID:jgw96,项目名称:Soundel,代码行数:24,代码来源:home.ts

示例5: getLastCharacter

export function getLastCharacter(account: string) {
  return localforage.getItem<string | null>(`${account}:lastCharacter`)
}
开发者ID:Kingdaro,项目名称:fchat,代码行数:3,代码来源:storage.ts

示例6: getAuthData

export function getAuthData() {
  return localforage.getItem<AuthData | null>('authData')
}
开发者ID:Kingdaro,项目名称:fchat,代码行数:3,代码来源:storage.ts

示例7: getState

 static async getState(userId: string): Promise<State> {
     return await localForage.getItem(LocalStore.getKey(userId)) as State;
 }
开发者ID:winken168,项目名称:Hitchhiker,代码行数:3,代码来源:local_store.ts

示例8: reject

 return new Promise<string>((resolve, reject) => {
   LocalForage.getItem<string>(getKey(key), (err, val) => {
     return err ? reject(err) : resolve(val);
   });
 });
开发者ID:luketurner,项目名称:scripsi,代码行数:5,代码来源:local.ts

示例9: loadCache

async function loadCache(context: Context, projectId: string) {
  const items = (await localForage.getItem(getProjectKey(projectId))) || {};
  context.setState({ cache: { projectId, items } });
}
开发者ID:skidding,项目名称:cosmos,代码行数:4,代码来源:index.ts

示例10: finishLogin

const actions: ActionTree<State, any> = {
  async finishLogin ({ commit, dispatch }) {
    const parseHash = pify(auth0.parseHash).bind(auth0)
    const authResult = await parseHash()
    const api = new Api(API_ENDPOINT)
    const loginResult = await api.authenticateUser(authResult.accessToken)
    commit('RECEIVE_USER', loginResult)
    dispatch('storeUser', loginResult)
  },

  async storeUser (ctx, user) {
    await localForage.setItem('user', user)
  },

  async getStoredUser ({ commit }) {
    const user = await localForage.getItem('user')
    if (user) commit('RECEIVE_USER', user)
  },

  async logout ({ commit }) {
    await localForage.removeItem('user')
    commit('RESET_USER')
  },

  async getRecipients ({ state, commit }) {
    const token = state.user.token
    const userId = state.user.id as string
    const api = new Api(API_ENDPOINT, token)
    const recipients = await api.getRecipients(userId)
    commit('RECEIVE_RECIPIENTS', recipients)
  }
开发者ID:timwis,项目名称:textblast,代码行数:31,代码来源:actions.ts


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