function EventStream(settings) {
    const defaults = {
        timeout: null,
        streamPath: '/notification/stream'
    };

    // User-provided settings from initialization
    this.settings = _.extend(defaults, settings);
    // Possible states are 'closed', 'stopped', 'started'
    this._state = 'closed';
    // Whether this is started (if so, holds the EventSource instance)
    this._eventSource = null;

    // Create context bindings only once, so they can be referenced when unbinding events
    this._onVisibilityStateChange = _.bind(this._onVisibilityStateChange, this);
    this._onMessage = _.bind(this._onMessage, this);
    this._onError = _.bind(this._onError, this);

    return _.extend(this, Backbone.Events);
}
function EventStream(settings) {
    const defaults = {
        timeout: null,
        streamPath: '/notification/stream'
    };

    
    this.settings = _.extend(defaults, settings);
    
    this._state = 'closed';
    
    this._eventSource = null;

    
    this._onVisibilityStateChange = _.bind(this._onVisibilityStateChange, this);
    this._onMessage = _.bind(this._onMessage, this);
    this._onError = _.bind(this._onError, this);

    return _.extend(this, Backbone.Events);
}
function EventStream ( settings ) { const defaults = { timeout : null , streamPath : '/notification/stream' } ; // User-provided settings from initialization this . settings = _ . extend ( defaults , settings ) ; // Possible states are 'closed', 'stopped', 'started' this . _state = 'closed' ; // Whether this is started (if so, holds the EventSource instance) this . _eventSource = null ; // Create context bindings only once, so they can be referenced when unbinding events this . _onVisibilityStateChange = _ . bind ( this . _onVisibilityStateChange , this ) ; this . _onMessage = _ . bind ( this . _onMessage , this ) ; this . _onError = _ . bind ( this . _onError , this ) ; return _ . extend ( this , Backbone . Events ) ; }
The EventStream type wraps window.EventSource to listen to the unified
per-user event channel endpoint using the SSE protocol. When events are
received on the SSE channel, this triggers a Backbone event of the form
'g:event.<type>' where <type> is the value of the event type field.
Listeners can bind to specific event types on the channel.
The EventStream type wraps window . EventSource to listen to the unified per - user event channel endpoint using the SSE protocol . When events are received on the SSE channel this triggers a Backbone event of the form g : event . <type > where <type > is the value of the event type field . Listeners can bind to specific event types on the channel .