Following on from this SO question I am now connecting and disconnecting the port to my native host based on when a user opens or closes a website tab. I do not know how to reconnect the port.
Originally when I only opened the port once I had;
if (typeof port !== 'undefined') return;
port = chrome.runtime.connectNative('name_to_host');
Now I have added port.disconnect();
when the user closes a certain tab or navigates away from the website.
This port is then still an object but is in a disconnected state.
What am I supposed to do with it now? Can I somehow "dispose" the port object or can I reconnect somehow?