tabex icon indicating copy to clipboard operation
tabex copied to clipboard

No way to cleanup the tabex.

Open Kukunin opened this issue 8 years ago • 3 comments

There is a situation, where tab should be 'disconnected' pragmatically, while page is still loaded. In such case tab shouldn't become a master tab. In this case it'd cool to have some cleanup method: client.disconnect() or so.

Currently, it's possible to workaround with __router__.__destroy__() method, but __router__ has intervals as well, so it still will try to achieve master tab.

Kukunin avatar Oct 10 '17 22:10 Kukunin

Sorry for silence. Could you clarify and split things by priority?

  • router does not clear timers in .__destroy__()
    • seems easy to fix
  • Client.destroy() with local router .__destroy__() after no clients left
    • can be postponed

puzrin avatar Nov 04 '17 09:11 puzrin

Currently, it's not a blocker for me, so the prioritization is up to you.

I worked around it with the following code:

  cleanupMutex: function() {
    if (this.mutex.__router__.__iframe__) {
      return this.mutex.__router__.__iframe__.remove();
    }
    this.mutex.__router__.__check_master__ = function() {};
    this.mutex.__router__.__destroy__();
    return this.mutex = null;
  }

this.mutex is an instance of tabex's Client.

Kukunin avatar Nov 09 '17 10:11 Kukunin

I found a bug in my workaround. If you destroyed the router once, you can reestablish it, because of caching here https://github.com/nodeca/tabex/blob/master/lib/index.js#L38. It will pick the destroyed router instead of creating new one

Kukunin avatar Dec 01 '17 10:12 Kukunin