Skip to content
Cycle.js driver for Server-Sent Events
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


NPM Build Status Coverage Status Dependency Status Dev Dependency Status

cycle-sse-driver is a Cycle.js driver for Server-Sent Events (SSE), a browser feature also known as EventSource. Server-Sent Events allow the server to continuously update the page with new events, without resorting to hacks like long-polling.


The driver function should be called with an SSE URL. In the following code, assume reasonably-defined view() and model() functions:

var makeSSEDriver = require('cycle-sse-driver');

function intent(responses) {
  return {
    eventOne$: responses.SSE('one'),
    eventTwo$: responses.SSE('two'),
    genericMessage$: responses.SSE()
} {
  var vtree$ = view(model(intent(responses)));
  return { DOM: vtree$ };
}, {
  DOM: makeDOMDriver('#myId'),
  SSE: makeSSEDriver('/sse-url')

As demonstrated above, the response function may be called with an event type, in which case only events of that type will be streamed. If the response function is called with no arguments, generic messages (i.e. messages sent without an event field) will be streamed. Since cycle-sse-driver is a source driver, the "main" function passed to need not return an object with an SSE member.

Like other Cycle.js drivers, the best way to use cycle-sse-driver is with browserify.


cycle-sse-driver is by Jess Austin and is distributed under the terms of the MIT License. Any and all potential contributions of issues and pull requests are welcome!

You can’t perform that action at this time.