2017-06-12 3 views
0

私はアプリケーションに関連するデータを格納するのにLocalStorageを使用するangular2サービスを持っています。HTMLローカルストレージサービスを、角2でindexedDBサービスに変換する方法は?

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); 
    } 
} 

データ(現在15メガバイト以上)アプリケーションのために成長したように、私はのlocalStorageの代わりIndexedDB v1.0を使用することを決めました。誰かがget()、set()、remove()関数を再定義するのを手伝ってもらえますか?メソッドを同期させる(特にget()メソッドやremove()メソッド)ようにしておきますか?

答えて

0

indexedDBメソッドは非同期です。私は敗北戦闘に反対することをお勧めします。

関連する問題