I have an angular2 service that employs LocalStorage to store the relevant data for my application.
import { Injectable } from '@angular/core';
@Injectable()
export class LocalStorageService {
get(item) {
return JSON.parse(localStorage.getItem(item));
}
set(target, item) {
localStorage.setItem(target, JSON.stringify(item));
}
remove(item) {
localStorage.removeItem(item);
}
}
As the data grew for the application(over 15 MB now), I decided to use IndexedDB v1.0 instead of LocalStorage. Can somebody help me redefine my get(), set() and remove() functions, keeping in mind that I want the methods to be synchronous,(especially, the get() and remove() methods)?
答案 0 :(得分:0)
indexedDB方法是异步的。我建议不要打败一场失败的战斗。