Angular @ngx-pwa/local-storage 不工作
Angular @ngx-pwa/local-storage is not working
我正在尝试使用以下方法将数据存储在浏览器的本地存储中
@ngx-pwa/local-storage 因为它在 regular/common 本地存储之上提供额外的 RxJs
运算符。
版本
"@angular/core": "^6.1.0",
"@ngx-pwa/local-storage": "^6.2.4"
component/service:
constructor(private storage: LocalStorage) {}
/// *** /////
const user: User = { firstName: 'lorem', lastName: 'ipsum' };
this.storage.setItem('user', user).subscribe(() => {});
在浏览器的Application/Local存储中=>数据为空。
@ngx-pwa/local-storage
在内部使用 indexedDB
使操作异步。
因此,当你执行异步存储操作时,它存储在indexedDB
中。所以你应该检查相应的选项卡:
Application -> IndexedDB -> ngStorage -> localStorage
请注意,此路径可能会根据配置发生变化
来自官方文档:
The localStorage API is simple to use but synchronous, so if you use
it too often, your app will soon begin to freeze.
The indexedDB API is asynchronous and efficient, but it's a mess to
use: you'll soon be caught by the callback hell, as it does not
support Promises yet.
Mozilla has done a very great job with the localForage library: a
simple API based on native localStorage, but internally stored via the
asynchronous indexedDB for performance. But it's built in ES5 old
school way and then it's a mess to include into Angular.
This module is based on the same idea as localForage, but built in
ES6+ and additionally wrapped into RxJS Observables to be homogeneous
with other Angular modules.
我正在尝试使用以下方法将数据存储在浏览器的本地存储中
@ngx-pwa/local-storage 因为它在 regular/common 本地存储之上提供额外的 RxJs
运算符。
版本
"@angular/core": "^6.1.0",
"@ngx-pwa/local-storage": "^6.2.4"
component/service:
constructor(private storage: LocalStorage) {}
/// *** /////
const user: User = { firstName: 'lorem', lastName: 'ipsum' };
this.storage.setItem('user', user).subscribe(() => {});
在浏览器的Application/Local存储中=>数据为空。
@ngx-pwa/local-storage
在内部使用 indexedDB
使操作异步。
因此,当你执行异步存储操作时,它存储在indexedDB
中。所以你应该检查相应的选项卡:
Application -> IndexedDB -> ngStorage -> localStorage
请注意,此路径可能会根据配置发生变化
来自官方文档:
The localStorage API is simple to use but synchronous, so if you use it too often, your app will soon begin to freeze.
The indexedDB API is asynchronous and efficient, but it's a mess to use: you'll soon be caught by the callback hell, as it does not support Promises yet.
Mozilla has done a very great job with the localForage library: a simple API based on native localStorage, but internally stored via the asynchronous indexedDB for performance. But it's built in ES5 old school way and then it's a mess to include into Angular.
This module is based on the same idea as localForage, but built in ES6+ and additionally wrapped into RxJS Observables to be homogeneous with other Angular modules.