Skip to content

Commit

Permalink
Use exported function to invoke SSE receiver so it can be overridden
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Aug 26, 2015
1 parent 5dac303 commit e1448c5
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/ServiceStack/js/ss-utils.js
Expand Up @@ -330,6 +330,15 @@
hold.close();
return $.ss.eventSource = es;
};
$.ss.invokeReceiver = function (r, cmd, el, msg, e, name) {
if (r) {
if (typeof (r[cmd]) == "function") {
r[cmd].call(el || r[cmd], msg, e);
} else {
r[cmd] = msg;
}
}
};
$.fn.handleServerEvents = function (opt) {
$.ss.eventSource = this[0];
opt = opt || {};
Expand Down Expand Up @@ -407,13 +416,7 @@
}
else {
var r = opt.receivers && opt.receivers[op] || $.ss.eventReceivers[op];
if (r) {
if (typeof (r[cmd]) == "function") {
r[cmd].call(el || r[cmd], msg, e);
} else {
r[cmd] = msg;
}
}
$.ss.invokeReceiver(r, cmd, el, msg, e, op);
}

if (opt.success) {
Expand Down

0 comments on commit e1448c5

Please sign in to comment.