本文整理汇总了TypeScript中@ionic/storage.Storage.set方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Storage.set方法的具体用法?TypeScript Storage.set怎么用?TypeScript Storage.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ionic/storage.Storage
的用法示例。
在下文中一共展示了Storage.set方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
this.http.get<IModuleConfig[]>(jsonPath).subscribe( async (jsonConfigList:IModuleConfig[]) => {
const appUpdateStorage = await this.storage.get("appUpdateAvailable");
for (let config of configList) {
if (localConfig.id == config.id) {
let configToSave = config;
for (let jsonConfig of jsonConfigList) {
if (jsonConfig.id == config.id) {
if (appUpdateStorage != config.appVersion) {
// check for new appVersion and notify user if new update is available
if (jsonConfig.appVersion) {
if (config.appVersion > jsonConfig.appVersion) {
this.storage.set("appUpdateAvailable", true);
} else if (jsonConfig.appVersion > config.appVersion) {
this.storage.set("appUpdateAvailable", jsonConfig.appVersion);
configToSave = jsonConfig;
}
} else { this.storage.set("appUpdateAvailable", true); }
} else if (jsonConfig.appVersion > config.appVersion) {
configToSave = jsonConfig;
}
}
}
// store up-to-date config in storage
this.storage.set("config", configToSave);
this.initPush(configToSave);
break;
}
}
});
示例2:
storage.get('dbVersion').then((val) => {
if(!(val instanceof UniversityListVersion))
val = {index: 0};
let dbObj:Container = universityService.getUniversities(val);
this.universities = dbObj.dbList;
storage.set('dbList', dbObj.dbList );
storage.set('dbVersion', dbObj.dbVersion );
})
示例3:
return Observable.create(observer => {
this.currentUser = null;
this.currentToken = null;
this.storage.set('currentToken', null);
this.storage.set('currentUser', null);
observer.next(true);
observer.complete();
});
示例4: constructor
constructor(public storage: Storage, public navCtrl: NavController, public navParams: NavParams, public auth:Auth,) {
this.storage.set('email', null);
this.storage.set('password', null);
this.fireAuth = firebase.auth();
this.auth.logout();
this.navCtrl.setRoot(LoginPage);
}
示例5: saveUiid
saveUiid(uuid: string) {
if(this.device.uuid != null) {
this.storage.set('uuid', uuid);
} else {
this.storage.set('uuid', Guid.create());
}
return true;
}
示例6:
return this.get(key).then((val)=>{
let id = value['id'];
if(val === null){
let initObj = {};
initObj[id] = value;
return this.storage.set(key, JSON.stringify(initObj));
}
let addObj = JSON.parse(val);
addObj[id] = value;
return this.storage.set(key, JSON.stringify(addObj));
});
示例7: Observable
let ob = new Observable(observer2 => {
this.storage
.set('geochronUsername', username)
.then(success => observer2.next(1), error => observer2.next(1));
this.storage
.set('geochronPassword', password)
.then(success => observer2.next(1), error => observer2.next(1));
this.storage
.set('loggedIn', true)
.then(success => observer2.next(1), error => observer2.next(1));
});
示例8:
this.storageApp.get('favoris').then(async val => {
if (!val) {
const fav = new Array<Media>();
fav.push(media);
this.storageApp.set('favoris', fav);
return
}
if (await this.isIncludes(val, media)) return
val.push(media);
this.storageApp.set('favoris', val);
})
示例9: performLogout
/**
* performLogout
*
* unsets current session, thus logging the user out
*/
performLogout() {
if (this.platform.is("cordova")) {
if (this.config) {
this.pushProv.unsubscribeToPush(this.config);
this.storage.set("config", null);
}
} else { this.storage.set("config", null); }
this.cache.clearAll();
this.storage.set("session", null);
this.storage.set("pushRegistered", false);
this.navCtrl.setRoot(SelectModulePage);
}
示例10: setTimeout
setTimeout(() => {
if (email && password) {
var token = "SomeRandomTokenFromServer";
this.storage.set('userToken', token);
resolve(token);
} else {
this.storage.set('userToken', null);
resolve(null);
}
}, 3000);