Share state between Atom windows


#1

Is there a way to share the state of a package between two or more Atom windows?

The use case I’m thinking of is like a music player inside Atom. Sharing the state so you can play/pause from any window.


#2

As I understand it, anything you store through a serialize() function should be constantly available across windows as long as you have a deserialize() function to read it back into your package’s working information. In the case of a music player, however, you don’t want to store its state (because you might close Atom, then turn off the music player, but Atom would still think it was on). You want each window asking the music player separately for its status. If you have only one window talking to the music player, you might run into undesired behavior if that window crashes, and then you have to figure out which window in Atom’s completely non-hierarchical structure you want to be running the show, and have your package keep track of that and hand off controllership if that window closed. That sounds like a ton of extra work and it would be better to have your package save no information about the status of the player and rely entirely on API calls for that information. It’s all local, so bandwidth isn’t an issue.


#3

I’m looking for a solution to share state (or messages) between two Atom windows that are open at the same time.

With the music player it would be nice to be able to run a pause command in any open Atom window and whichever Atom window has the <audio> tag playing to pause it.

Are the any IPC objects exposed in Atom?