a25b5e9823
State manager improvements Fix local storage parse New layer (119)
18 lines
545 B
JavaScript
18 lines
545 B
JavaScript
console.time('open');
|
|
caches.open('sessions').then(cache => {
|
|
console.timeEnd('open');
|
|
cache.put('/state', new Response(JSON.stringify(appStateManager.state), {headers: {'Content-Type': 'application/json'}}));
|
|
});
|
|
|
|
console.time('match');
|
|
caches.open('sessions').then(async(cache) => {
|
|
const response = await cache.match('/state');
|
|
const promise = response.json();
|
|
promise.then((json) => {
|
|
console.timeEnd('match');
|
|
});
|
|
});
|
|
|
|
console.time('getItem');
|
|
var value = JSON.parse(localStorage.getItem('state'));
|
|
console.timeEnd('getItem'); |