0

I wanna improve my VueJS application system.

Currently, each browser tab once per 20 seconds makes synchronization with the server - getting notifications and the latest settings.

It's problematic because a typical user often has 20+ opened tabs, so each synchronizes itself.

I know, that I can share the Vuex Store between tabs, using localStorage, and currently I'm doing this, so I don't have to synchronize everyone tab, cause if one of them synchronizes, all of them will have current data about app notifications and settings.

So the question is - how to do it?

I tried using this solution, but what if the user closes the tab? How to control that, one of the tabs synchronized the data?

Thanks in advance, have a nice day!

Comsphere
  • 137
  • 2
  • 11
Simon Jan
  • 22
  • 1
  • 6
  • here have some solution please check it up https://github.com/gabrielmbmb/vuex-multi-tab-state – Comsphere Dec 10 '20 at 09:19
  • @Comsphere, yes, I know and currently using it, thanks. Synchronizing Store between tabs is easy to do, but I don know how to limit tabs, which can synchronize with the server to only one. – Simon Jan Dec 10 '20 at 09:34
  • Is it better to check on how many tab is being open by using the javascript here? function logTabsForWindows(windowInfoArray) { for (windowInfo of windowInfoArray) { console.log(`Window: ${windowInfo.id}`); console.log(windowInfo.tabs.map((tab) => {return tab.url})); } } var gettingAll = browser.windows.getAll({populate: true}) gettingAll.then(logTabsForWindows); – Comsphere Dec 10 '20 at 09:50
  • Hmmm, what about `ReferenceError: browser is not defined` error? – Simon Jan Dec 10 '20 at 10:47
  • sorry for late reply here have some tips for you https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/windows/getAll – Comsphere Dec 11 '20 at 03:10
  • Yeah, I found it, but still I'm getting the same error. Then I've tried `let browser = window.browser || window.chrome`, and now I'm getting: `Cannot read property 'getAll' of undefined`. – Simon Jan Dec 12 '20 at 08:40
  • Isn't it a feature only for the browser extensions? – Simon Jan Dec 12 '20 at 09:09
  • it can't customize for whole browser such as edge, firefox, chrome, here is some chrome example to use it https://developer.chrome.com/docs/extensions/reference/tabs/#type-Tab – Comsphere Dec 14 '20 at 02:23
  • here is some demo for you, https://codepen.io/AndrewTechLead/pen/VwKPGoW, suggest to put this link in new browser, with this new browser open several tab to try. – Comsphere Dec 14 '20 at 03:23

0 Answers0