I have an angular 8+ application, and i am trying to work with localstorage and sessionstorage. Listening to sessionstorage or localstorage changes. Since its angular i am using the Event Manager class :
constructor( private elementRef: ElementRef, private eventManager: EventManager) {
this.eventManager.addGlobalEventListener('window', 'storage', () => {
console.log('Event listener.....');
});
}
When i session storage set item, the above function does not execute. it is only executed when i go to the DevTools -> Application -> Storage then remove the item. I have read somewhere that the reason it is not executing is because it cant execute on the current browser tab/current window. Is the a way to make the event listener execute on current window or browser tab When the button is clicked ? i am using Chrome browser.