tejacques / crosstab

A utility library for cross-tab communication using localStorage.
Apache License 2.0
364 stars 58 forks source link

Need ability to set a custom master tab #70

Closed Shah-Nisarg closed 6 years ago

Shah-Nisarg commented 7 years ago

I think it would be quite helpful to add the feature of setting a custom master tab from any of the other tabs. One of the use cases would be when someone wants one of the non-master tabs to open a websocket and disconnect from the master tab.

For example, in my case, I want to limit the number of sockets my application opens. But at the same time, I want to avoid cases where user experience is affected due to closed sockets. So, by default, my app opens the connection on the master tab. But when the user interacts with one of the other tabs, I would want to make it a master tab and then open a socket. At the same time, previous master tab will close the socket.

Shah-Nisarg commented 7 years ago

I can create a PR for this if you want.

tejacques commented 7 years ago

Ah interesting, so basically having some notion of promoting a specific tab to master?

The way I would implement that is to basically close and re-init the crosstab instance on the current master, and to steal its ID on the one you want to promote (or something similar).

tejacques commented 7 years ago

PR would be welcome