Search code examples
javascriptjqueryjquery-pluginsnoty

Jquery noty: sync notifications between browser's tabs


Each tab of app is independently subscribed to server's messages. To display them I use jquery noty plugin.

Older tabs has got more notifications than recently opened. I need to sync them, i.e. each tab has got the equal noties. Is there any technology or even ready-to-use solution to achieve this?

Thanks for help


Solution

  • Possible solution is to use localStorage.

    Algo is:

    1. When notification has comed from server, we add it to localStorage.
    2. When user removes noty, we delete it from localStorage.
    3. Other tabs periodically check lS for updates and add necessary noties.

    To identify noty, it's necessary to use its id: var n = noty({ text: 'NOTY - a jquery notification library!' }); console.log(n.options.id); // it prints id to browser's console