本文整理汇总了TypeScript中ionic-cache.CacheService类的典型用法代码示例。如果您正苦于以下问题:TypeScript CacheService类的具体用法?TypeScript CacheService怎么用?TypeScript CacheService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CacheService类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getAppointments
public getAppointments(config:IModuleConfig, token, forceReload?): Observable<AppointConfig> {
var url = config.moodleServiceEndpoint;
var courseID = config.courseID;
var accessToken = config.authorization.credentials.authHeader.accessToken;
var today = new Date();
var oneYearLater = new Date();
oneYearLater.setFullYear(today.getFullYear()+1);
let params:HttpParams = new HttpParams()
.append("wstoken", token)
.append("wsfunction", "local_reflect_get_calendar_entries")
.append("moodlewsrestformat", "json")
.append("options[userevents]", "0")
.append("options[siteevents]", "0")
.append("options[timestart]", Math.floor(today.getTime() / 1000).toString())
.append("options[timeend]", Math.floor(oneYearLater.getTime() / 1000).toString())
.append("options[ignorehidden]", "1")
.append("courseID", courseID);
let headers:HttpHeaders = new HttpHeaders()
.append("Authorization", accessToken);
let request = this.http.get<AppointConfig>(url, {headers:headers,params:params});
if (forceReload) { this.cache.removeItem("cachedEvents"); }
return this.cache.loadFromObservable("cachedEvents", request);
}
示例2:
this.platform.ready().then(() => {
this.cache.setDefaultTTL(60 * 60 * 2); // 2h caching
this.cache.setOfflineInvalidate(false); // keep cached results when device is offline
if (this.platform.is("cordova")) {
this.splashScreen.hide();
this.statusBar.styleDefault();
this.storage.get("hiddenCards").then(array => {
if (array == undefined) {
this.storage.set("hiddenCards", ["-1"]);
}
});
this.storage.get("scheduledEvents").then(array => {
if (array == undefined) {
this.storage.set("scheduledEvents", ["-1"]);
}
});
}
});
示例3: getAnsweredQuestions
public getAnsweredQuestions(config:IModuleConfig, token, forceReload?): Observable<QuestionConfig> {
var url = config.moodleServiceEndpoint;
var courseID = config.courseID;
var accessToken = config.authorization.credentials.authHeader.accessToken;
let params:HttpParams = new HttpParams()
.append("wstoken", token)
.append("wsfunction", "local_reflect_get_completed_feedbacks")
.append("moodlewsrestformat", "json")
.append("courseID", courseID);
let headers:HttpHeaders = new HttpHeaders()
.append("Authorization", accessToken);
let request = this.http.get<QuestionConfig>(url, {headers:headers,params:params});
if (forceReload) { this.cache.removeItem("cachedCompletedQuestions"); }
return this.cache.loadFromObservable("cachedCompletedQuestions", request);
}
示例4: 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);
}