Recently I had to create a solution where an AngularJS app had to communicate with another window that displayed a Sigma.js graph, animating movement through the graph in response to using the UI of the AngularJS app.
So I implemented a very basic client-side message queue. It’s no AMQP, but I think it’s still pretty cool, so I though I’d share anyway.
It is actually pretty basic. LocalStorage doesn’t support complex types so you have to JSON encode and decode every time you want to send or check for new messages, but that’s native and not an issue as long as your poll / consume interval is reasonable. Add some queue semantics, share the code between windows, use the same namespace, e voilà, a message queue of sorts.
Thanks for reading.