Cross-tab state synchronization with localStorage
This commit is contained in:
parent
4477f4b5c7
commit
f831f905a5
@ -10,7 +10,13 @@ if((!state.cid) && (cookie.get('cid'))) state.resources = cookie.get('cid');
|
||||
if((!state.host) && (cookie.get('host'))) state.resources = cookie.get('host');
|
||||
if((!state.resources) && (cookie.get('vista.resources'))) state.resources = cookie.get('vista.resources');
|
||||
if((!state.practitioner) && (cookie.get('vista.practitioner'))) state.practitioner = JSON.parse(cookie.get('vista.practitioner'));
|
||||
watch(state, value => cookie.set('state', JSON.stringify(value), 45), { immediate: true, deep: true });
|
||||
window.addEventListener('storage', function(evt) {
|
||||
if((evt.storageArea == window.localStorage) && (evt.key == 'state') && (evt.newValue)) Object.assign(state, JSON.parse(evt.newValue));
|
||||
});
|
||||
watch(state, function(value) {
|
||||
cookie.set('state', value = JSON.stringify(value), 45);
|
||||
window.localStorage.setItem('state', value);
|
||||
}, { immediate: true, deep: true });
|
||||
|
||||
function RPCError(type, ...args) {
|
||||
this.name = type;
|
||||
|
Loading…
Reference in New Issue
Block a user