Subscription Queries with a javascript client

I just wanted to share some work I’ve done to solve what has been a pretty tricky issue: integrating a javascript front end with subscription queries.

I have prototype available on gitbub that might help you if you need to do the same thing:

My solution uses Server Sent Events and requires a polyfill in order to support IE and also to support the passing of my JWT authentication token.

Let me know what you think.


I’ve made a bunch of modifications. The front end is a little messy because I am trying to keep it simple by just depending jquery rather than angular or react or something.

The current implementation demonstrates subscribing to a list of (basket) models in addition to subscribing to a given (basket) model.

One of the issues that I’m still wrestling with is the separation of the initial result with the flux of incremental updates. I feel like there should be a way to subscribe and get the both the initial state back plus the incremental updates. As it it now I must subscribe to the updates and then go get the current state an integrate it all on the client.

Hi Troy,

you can merge the initial result and the updates into a single Flux quite easily, if their content types are the same:

Flux results = r.initialResult().concatWith(r.updates())

Also, why does the client need to fetch the initial result in a separate request? You could simply send the initial result as the first SSE, and the updates following that.


Hi all,

As an example of how to combine ‘initialResult’ and ‘incrementalUpdates’ you can take a look at this small example I built to demonstrate usage of subscription queries.


Allard and Milan,

Thanks for the replies! I still have a lot to learn about Reactor!