gazay / gon

Your Rails variables in your JS
MIT License
3.05k stars 184 forks source link

gon.watch not update variable in different browser windows. #242

Open vader1359 opened 6 years ago

vader1359 commented 6 years ago

I set up a gon variable for checking if current user is available in controller. gon.watch.has_current_user = current_user.present? I open a page (with current user presents) and duplicate that page to a new browser window. I logged out in one page and call gon.watch('has_current_user'), then call alert(gon.has_current_user in the console. The variable was updated from true to false successfully. Now I called the same two methods in the page I had not logged out. I assume that the variable must be checked and updated again by gon.watch and become false, too. However, the current_user still existed there. Why?