1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-26 17:59:14 +00:00
Radarr/UI/Mixins/backbone.signalr.mixin.js
2013-09-11 17:42:53 -07:00

35 lines
874 B
JavaScript

'use strict';
define(
[
'signalR'
], function () {
_.extend(Backbone.Collection.prototype, {
bindSignalR: function () {
var collection = this;
var processMessage = function (options) {
var model = new collection.model(options.resource, {parse: true});
collection.add(model, {merge: true});
console.log(options.action + ": %O", options.resource);
};
require(
[
'app'
], function (app) {
collection.listenTo(app.vent, 'server:' + collection.url.replace('/api/', ''), processMessage)
});
return this;
},
unbindSignalR: function () {
}});
});