lucuma
lucuma

Reputation: 18339

Service Stack SSE Javascript Client - Uncaught TypeError

I'm working on a simple SSE javascript client and reviewing the various examples the following should work:

 var source = new EventSource(
        '/event-stream?channel=siteevent&t=' + new Date().getTime());

    source.addEventListener('error', function (e) {
        console.log(e);
        addEntry({ msg: "ERROR!", cls: "error" });
    }, false);
    $.ss.eventReceivers = { "document": document };
    $(source).handleServerEvents({
       handlers: {
            onHeartbeat: function (msg, e) { if (console)  
              console.log("onHeartbeat", msg, e); },
            onMessage: function (msg, e) { // fired after every message
                console.log(msg);
            }
        },
        receivers: {
            //... Register any receivers
        }
    });

It generates an error. If I add all the handlers they generate more of the same errors.

jquery 2.1.1

Uncaught TypeError: fn.cal is not a function
    at EventSource.onMessage (ss-utils.js:566)

jquery 3.1.x

Uncaught TypeError: Cannot assign to read only property 'target' of object '#' at Function.r.extend.r.fn.extend (jquery.min.js:2) at EventSource.onMessage (ss-utils.js:511)

Upvotes: 0

Views: 167

Answers (1)

lucuma
lucuma

Reputation: 18339

There is a bug in the /js/ss-utils.js included script on line 566. It should be fn.call instead of fn.cal. I'm going to leave this answer in case others are having issues with the js SSE library included with Service Stack (core).

Upvotes: 1

Related Questions