rtfeldman / elm-spa-example

A Single Page Application written in Elm
https://dev.to/rtfeldman/tour-of-an-open-source-elm-spa
MIT License
3.28k stars 530 forks source link

Send the parsed stringified JSON to Elm in localStorate event listener #83

Open rlopzc opened 4 years ago

rlopzc commented 4 years ago

The event.newValue contains the stringified version of the store. In order to send the same value as in line 38, we need to parse it before sending it.

In my case, I was updating the token of the session in multiple tabs. It was incorrectly sending the new Viewer to each tab. The session was getting deleted.

With this change, any tab would get the updated Viewer without the user noticing