How do I stay on the same Asteroid instance on a Chrome Extension?


#1

I am using the library mondora/asteroid in order to build a Chrome extension while using a Meteor backend. I am having an issue storing and carrying over the asteroid instance from the background page or when I open or close the popup. I need to keep track of if the user is logged in or not.

To create the asteroid instance, I use:

const Asteroid = createClass();
asteroid = new Asteroid({
  endpoint: 'ws://localhost:3000/
});

I have tried passing the asteroid instance through chrome.storage.local.set, but when I try to use it with chrome.storage.local.get, I get an error that doesn’t allow me to use asteroid functions. I’m using React and am able to pass asteroid down as a prop element to child components, so I am not sure why it is not working for me when using chrome.storage.

I also noticed that there is some chrome specific code in the asteroid library, but it isn’t documented and I can’t quite figure out how to use it.

What is the best way to communicate back and forth between the popup and background?

Any ideas or help would be amazing!