1

In my AngularJS application two windows communicate through localStorage in order to use a single websocket connection. The main window listens to messages from server putting incoming data into a localStorage property. The child window use an angular $watch on this property to put incoming data into a grid. The use of different windows and a single connection is a requirement.

The problem is that the controller of the child window seems not to be able to watch the localStorage property until the browser development tool (F12) is not open.

How can I fix this issue?

retrobitguy
  • 535
  • 1
  • 6
  • 18

1 Answers1

1

I have an angular project also using localstorage and localforage.js. This statement is really narrowing your problem to the development tools though, no?:

"until the browser development tool (F12) is not open."

Make sure this box is unchecked.

enter image description here

Reload the page and try again.

Or you might try this solution: Using localstorage checks in a different window using window.postMessage()

Our QA team reports several bugs stemming from having two windows open with localstorage, so the data access has to be tightly synchronized. So the child window would send data to the parent which would handle localstorage.

smurtagh
  • 1,187
  • 9
  • 17
  • Thank you, but the uncheck of "Disable check" didn't worked. I will explain better: when I open the child window, the grid gets filled with the data inside the localStorage, but it cannot get the updates. Then, if I open the developer tool, it starts to get the updates. Then, if I lose the focus of the child window, it doesn't get the updates. If I reopen the developer tools it starts to work again. – retrobitguy Jun 14 '17 at 13:46
  • is it possible you have the same bug as mentioned here?: https://stackoverflow.com/a/42975984/6254070 Which browser are you using? – smurtagh Jun 14 '17 at 13:53