[{"data":1,"prerenderedAt":6105},["ShallowReactive",2],{"article_list_backbone_":3},[4],{"_path":5,"_dir":6,"_draft":7,"_partial":7,"_locale":8,"title":9,"description":10,"publishDate":11,"tags":12,"image":16,"excerpt":10,"body":17,"_type":6096,"_id":6097,"_source":6098,"_file":6099,"_stem":6100,"_extension":6101,"author":6102},"/ckeefer/2014-6/backbonesocketsync","2014-6",false,"","Websockets for Backbone","Backbone's had some of its thunder stolen lately by trendier frameworks like Meteor and Angular; for good reason, in most cases, as without the prosthetic functionality offered by the likes of Marionette, Backbone's view handling (amongst a few other lacks and warts) is really just 'roughed in'.","2014-06-25",[13,14,15],"js","websockets","backbone","/ckeefer/2014-6/img/WebsocketsPlusBackbone.png",{"type":18,"children":19,"toc":6094},"root",[20,39,44,49,63,95,100,1985,1990,2171,2176,2289,2308,2313,2365,2711,2731,2929,2934,3152,3180,3192,3205,3258,3272,3369,3374,3593,3598,3855,3867,3872,3877,6083,6088],{"type":21,"tag":22,"props":23,"children":24},"element","p",{},[25,28,37],{"type":26,"value":27},"text","Backbone's had some of its thunder stolen lately by trendier frameworks like Meteor and Angular; for good reason, in most cases, as without the prosthetic functionality offered by the likes of ",{"type":21,"tag":29,"props":30,"children":34},"a",{"href":31,"rel":32},"http://marionettejs.com",[33],"nofollow",[35],{"type":26,"value":36},"Marionette",{"type":26,"value":38},", Backbone's view handling (amongst a few other lacks and warts) is really just 'roughed in'.",{"type":21,"tag":22,"props":40,"children":41},{},[42],{"type":26,"value":43},"But the fact that a framework like marionette can be built on top of Backbone is a testament to Backbone's flexibility - after all, as the name suggests, Backbone is really just the 'skeleton' of your app, and it's willing to be fit into place however you need it to be.",{"type":21,"tag":22,"props":45,"children":46},{},[47],{"type":26,"value":48},"For instance: Backbone's default persistance method is via jQuery's ajax - make a request to the server using one of the standard HTTP methods to persists changes to models in a collection to the server-side db. Works great, but maybe you need something faster/better/stronger/etc.",{"type":21,"tag":22,"props":50,"children":51},{},[52,54,61],{"type":26,"value":53},"Like, say, ",{"type":21,"tag":29,"props":55,"children":58},{"href":56,"rel":57},"https://developer.mozilla.org/en/docs/WebSockets",[33],[59],{"type":26,"value":60},"WebSockets",{"type":26,"value":62},".",{"type":21,"tag":22,"props":64,"children":65},{},[66,68,75,77,84,86,93],{"type":26,"value":67},"Let's replace Backbone's standard method of persistance via ajax with WebSockets! To do this, we'll take advantage of the excellent ",{"type":21,"tag":29,"props":69,"children":72},{"href":70,"rel":71},"http://socket.io",[33],[73],{"type":26,"value":74},"socket.io",{"type":26,"value":76}," client library (and, of course, you'll need the appropriate server-side library for your chosen language - via ",{"type":21,"tag":78,"props":79,"children":81},"code",{"className":80},[],[82],{"type":26,"value":83},"npm install socket.io",{"type":26,"value":85}," if you're using Node.js, a package like ",{"type":21,"tag":29,"props":87,"children":90},{"href":88,"rel":89},"https://github.com/abourget/gevent-socketio",[33],[91],{"type":26,"value":92},"Gevent Socket.io",{"type":26,"value":94}," if you're using Python, etc.).",{"type":21,"tag":22,"props":96,"children":97},{},[98],{"type":26,"value":99},"Let's take a look at the code, and then break it down:",{"type":21,"tag":101,"props":102,"children":106},"pre",{"className":103,"code":104,"language":105,"meta":8,"style":8},"language-javascript shiki shiki-themes github-light github-dark","/**\n * Copyright (c) Christopher Keefer. All Rights Reserved.\n *\n * Overrides the default transport for Backbone syncing to use websockets via socket.io.\n */\n(function(Backbone, $, _, io){\n    var urlError = function(){\n        throw new Error('A \"url\" property or function must be specified.');\n    },\n        eventEmit = io.EventEmitter.prototype.emit,\n        ajaxSync = Backbone.sync;\n\n    /**\n     * Preserve the standard, jquery ajax based persistance method as ajaxSync.\n     */\n    Backbone.ajaxSync = function(method, model, options){\n        return ajaxSync.call(this, method, model, options);\n    };\n\n    /**\n     * Replace the standard sync function with our new, websocket/socket.io based solution.\n     */\n    Backbone.sync = function(method, model, options){\n        var opts = _.extend({}, options),\n            defer = $.Deferred(),\n            promise = defer.promise(),\n            namespace,\n            socket;\n\n        opts.url = (opts.url) ? _.result(opts, 'url') : (model.url) ? _.result(model, 'url') : void 0;\n        // If no url property has been specified, throw an error, as per the standard Backbone sync\n        if (!opts.url) urlError();\n        // Transform the url into a namespace\n        namespace = Backbone.Model.prototype.namespace.call(this, opts.url);\n        // Determine what data we're sending, and ensure id is present if we're performing a PATCH call\n        if (!opts.data && model) opts.data = opts.attrs || model.toJSON(options) || {};\n        if ((opts.data.id === null || opts.data.id === void 0) && opts.patch === true && model){\n            opts.data.id = model.id;\n        }\n        // Determine which websocket to use - set in options or on model\n        socket = opts.socket || model.socket;\n        // Add a listener for our namespaced method, and resolve or reject our deferred based on the response\n        socket.once(namespace+method, function(res){\n            var success = (res && res.success); // Expects server json response to contain a boolean 'success' field\n            if (success)\n            {\n                if (_.isFunction(options.success)) options.success(res);\n                defer.resolve(res);\n                return;\n            }\n            if (_.isFunction(options.error)) options.error(res);\n            defer.reject(res);\n        });\n\n        // Emit our namespaced method and the model+opts data\n        socket.emit(namespace+method, opts.data);\n\n        // Trigger the request event on the model, as per backbone spec\n        model.trigger('request', model, promise, opts);\n        // Return the promise for us to use as per usual (hanging .done blocks off, add to a .when, etc.)\n        return promise;\n    };\n\n    /**\n     * Break url apart to create namespace - every '/' save any pre/post-fixing the url will become a ':' indicating\n     * namespace - so a collection that maps to /api/posts will now have its events on the namespace\n     * api:posts: (ie. api:posts:create, api:posts:delete, etc.), and a model that maps to /api/posts/21\n     * will have events on api:posts:21: (ie. api:posts:21:update, api:posts:21:patch, etc.)\n     * @param {string=} url\n     */\n    Backbone.Model.prototype.namespace = function(url){\n        url = url || this.url();\n        return _.trim(url, '/').replace('/', ':') + \":\";\n    };\n\n    /**\n     * Override EventEmitter.emit and SocketNamespace reference for socket.io to add a catch all case for the\n     * wildcard ('*') character. Now, socket.on('*') will catch any event, with the name of the caught event\n     * passed to the handler as the first argument.\n    */\n    io.EventEmitter.prototype.emit = function(name){\n        var args = Array.prototype.slice.call(arguments, 1);\n\n        eventEmit.apply(this, ['*', name].concat(args));\n        eventEmit.apply(this, [name].concat(args));\n    };\n    io.SocketNamespace.prototype.$emit = io.EventEmitter.prototype.emit;\n})(Backbone, jQuery, _, io);\n","javascript",[107],{"type":21,"tag":78,"props":108,"children":109},{"__ignoreMap":8},[110,122,131,140,149,158,217,247,281,290,320,338,348,357,366,375,428,461,470,478,486,495,503,552,585,613,640,649,658,666,767,776,810,819,863,872,941,1018,1036,1045,1054,1081,1090,1136,1173,1187,1196,1230,1248,1261,1270,1300,1318,1327,1335,1344,1370,1378,1387,1415,1424,1437,1445,1453,1461,1470,1479,1488,1497,1521,1529,1572,1611,1682,1690,1698,1706,1715,1724,1733,1742,1784,1845,1853,1900,1933,1941,1976],{"type":21,"tag":111,"props":112,"children":115},"span",{"class":113,"line":114},"line",1,[116],{"type":21,"tag":111,"props":117,"children":119},{"style":118},"--shiki-default:#6A737D;--shiki-dark:#6A737D",[120],{"type":26,"value":121},"/**\n",{"type":21,"tag":111,"props":123,"children":125},{"class":113,"line":124},2,[126],{"type":21,"tag":111,"props":127,"children":128},{"style":118},[129],{"type":26,"value":130}," * Copyright (c) Christopher Keefer. All Rights Reserved.\n",{"type":21,"tag":111,"props":132,"children":134},{"class":113,"line":133},3,[135],{"type":21,"tag":111,"props":136,"children":137},{"style":118},[138],{"type":26,"value":139}," *\n",{"type":21,"tag":111,"props":141,"children":143},{"class":113,"line":142},4,[144],{"type":21,"tag":111,"props":145,"children":146},{"style":118},[147],{"type":26,"value":148}," * Overrides the default transport for Backbone syncing to use websockets via socket.io.\n",{"type":21,"tag":111,"props":150,"children":152},{"class":113,"line":151},5,[153],{"type":21,"tag":111,"props":154,"children":155},{"style":118},[156],{"type":26,"value":157}," */\n",{"type":21,"tag":111,"props":159,"children":161},{"class":113,"line":160},6,[162,168,174,178,184,189,194,198,203,207,212],{"type":21,"tag":111,"props":163,"children":165},{"style":164},"--shiki-default:#24292E;--shiki-dark:#E1E4E8",[166],{"type":26,"value":167},"(",{"type":21,"tag":111,"props":169,"children":171},{"style":170},"--shiki-default:#D73A49;--shiki-dark:#F97583",[172],{"type":26,"value":173},"function",{"type":21,"tag":111,"props":175,"children":176},{"style":164},[177],{"type":26,"value":167},{"type":21,"tag":111,"props":179,"children":181},{"style":180},"--shiki-default:#E36209;--shiki-dark:#FFAB70",[182],{"type":26,"value":183},"Backbone",{"type":21,"tag":111,"props":185,"children":186},{"style":164},[187],{"type":26,"value":188},", ",{"type":21,"tag":111,"props":190,"children":191},{"style":180},[192],{"type":26,"value":193},"$",{"type":21,"tag":111,"props":195,"children":196},{"style":164},[197],{"type":26,"value":188},{"type":21,"tag":111,"props":199,"children":200},{"style":180},[201],{"type":26,"value":202},"_",{"type":21,"tag":111,"props":204,"children":205},{"style":164},[206],{"type":26,"value":188},{"type":21,"tag":111,"props":208,"children":209},{"style":180},[210],{"type":26,"value":211},"io",{"type":21,"tag":111,"props":213,"children":214},{"style":164},[215],{"type":26,"value":216},"){\n",{"type":21,"tag":111,"props":218,"children":220},{"class":113,"line":219},7,[221,226,232,237,242],{"type":21,"tag":111,"props":222,"children":223},{"style":170},[224],{"type":26,"value":225},"    var",{"type":21,"tag":111,"props":227,"children":229},{"style":228},"--shiki-default:#6F42C1;--shiki-dark:#B392F0",[230],{"type":26,"value":231}," urlError",{"type":21,"tag":111,"props":233,"children":234},{"style":170},[235],{"type":26,"value":236}," =",{"type":21,"tag":111,"props":238,"children":239},{"style":170},[240],{"type":26,"value":241}," function",{"type":21,"tag":111,"props":243,"children":244},{"style":164},[245],{"type":26,"value":246},"(){\n",{"type":21,"tag":111,"props":248,"children":250},{"class":113,"line":249},8,[251,256,261,266,270,276],{"type":21,"tag":111,"props":252,"children":253},{"style":170},[254],{"type":26,"value":255},"        throw",{"type":21,"tag":111,"props":257,"children":258},{"style":170},[259],{"type":26,"value":260}," new",{"type":21,"tag":111,"props":262,"children":263},{"style":228},[264],{"type":26,"value":265}," Error",{"type":21,"tag":111,"props":267,"children":268},{"style":164},[269],{"type":26,"value":167},{"type":21,"tag":111,"props":271,"children":273},{"style":272},"--shiki-default:#032F62;--shiki-dark:#9ECBFF",[274],{"type":26,"value":275},"'A \"url\" property or function must be specified.'",{"type":21,"tag":111,"props":277,"children":278},{"style":164},[279],{"type":26,"value":280},");\n",{"type":21,"tag":111,"props":282,"children":284},{"class":113,"line":283},9,[285],{"type":21,"tag":111,"props":286,"children":287},{"style":164},[288],{"type":26,"value":289},"    },\n",{"type":21,"tag":111,"props":291,"children":293},{"class":113,"line":292},10,[294,299,304,309,315],{"type":21,"tag":111,"props":295,"children":296},{"style":164},[297],{"type":26,"value":298},"        eventEmit ",{"type":21,"tag":111,"props":300,"children":301},{"style":170},[302],{"type":26,"value":303},"=",{"type":21,"tag":111,"props":305,"children":306},{"style":164},[307],{"type":26,"value":308}," io.EventEmitter.",{"type":21,"tag":111,"props":310,"children":312},{"style":311},"--shiki-default:#005CC5;--shiki-dark:#79B8FF",[313],{"type":26,"value":314},"prototype",{"type":21,"tag":111,"props":316,"children":317},{"style":164},[318],{"type":26,"value":319},".emit,\n",{"type":21,"tag":111,"props":321,"children":323},{"class":113,"line":322},11,[324,329,333],{"type":21,"tag":111,"props":325,"children":326},{"style":164},[327],{"type":26,"value":328},"        ajaxSync ",{"type":21,"tag":111,"props":330,"children":331},{"style":170},[332],{"type":26,"value":303},{"type":21,"tag":111,"props":334,"children":335},{"style":164},[336],{"type":26,"value":337}," Backbone.sync;\n",{"type":21,"tag":111,"props":339,"children":341},{"class":113,"line":340},12,[342],{"type":21,"tag":111,"props":343,"children":345},{"emptyLinePlaceholder":344},true,[346],{"type":26,"value":347},"\n",{"type":21,"tag":111,"props":349,"children":351},{"class":113,"line":350},13,[352],{"type":21,"tag":111,"props":353,"children":354},{"style":118},[355],{"type":26,"value":356},"    /**\n",{"type":21,"tag":111,"props":358,"children":360},{"class":113,"line":359},14,[361],{"type":21,"tag":111,"props":362,"children":363},{"style":118},[364],{"type":26,"value":365},"     * Preserve the standard, jquery ajax based persistance method as ajaxSync.\n",{"type":21,"tag":111,"props":367,"children":369},{"class":113,"line":368},15,[370],{"type":21,"tag":111,"props":371,"children":372},{"style":118},[373],{"type":26,"value":374},"     */\n",{"type":21,"tag":111,"props":376,"children":378},{"class":113,"line":377},16,[379,384,389,393,397,401,406,410,415,419,424],{"type":21,"tag":111,"props":380,"children":381},{"style":164},[382],{"type":26,"value":383},"    Backbone.",{"type":21,"tag":111,"props":385,"children":386},{"style":228},[387],{"type":26,"value":388},"ajaxSync",{"type":21,"tag":111,"props":390,"children":391},{"style":170},[392],{"type":26,"value":236},{"type":21,"tag":111,"props":394,"children":395},{"style":170},[396],{"type":26,"value":241},{"type":21,"tag":111,"props":398,"children":399},{"style":164},[400],{"type":26,"value":167},{"type":21,"tag":111,"props":402,"children":403},{"style":180},[404],{"type":26,"value":405},"method",{"type":21,"tag":111,"props":407,"children":408},{"style":164},[409],{"type":26,"value":188},{"type":21,"tag":111,"props":411,"children":412},{"style":180},[413],{"type":26,"value":414},"model",{"type":21,"tag":111,"props":416,"children":417},{"style":164},[418],{"type":26,"value":188},{"type":21,"tag":111,"props":420,"children":421},{"style":180},[422],{"type":26,"value":423},"options",{"type":21,"tag":111,"props":425,"children":426},{"style":164},[427],{"type":26,"value":216},{"type":21,"tag":111,"props":429,"children":431},{"class":113,"line":430},17,[432,437,442,447,451,456],{"type":21,"tag":111,"props":433,"children":434},{"style":170},[435],{"type":26,"value":436},"        return",{"type":21,"tag":111,"props":438,"children":439},{"style":164},[440],{"type":26,"value":441}," ajaxSync.",{"type":21,"tag":111,"props":443,"children":444},{"style":228},[445],{"type":26,"value":446},"call",{"type":21,"tag":111,"props":448,"children":449},{"style":164},[450],{"type":26,"value":167},{"type":21,"tag":111,"props":452,"children":453},{"style":311},[454],{"type":26,"value":455},"this",{"type":21,"tag":111,"props":457,"children":458},{"style":164},[459],{"type":26,"value":460},", method, model, options);\n",{"type":21,"tag":111,"props":462,"children":464},{"class":113,"line":463},18,[465],{"type":21,"tag":111,"props":466,"children":467},{"style":164},[468],{"type":26,"value":469},"    };\n",{"type":21,"tag":111,"props":471,"children":473},{"class":113,"line":472},19,[474],{"type":21,"tag":111,"props":475,"children":476},{"emptyLinePlaceholder":344},[477],{"type":26,"value":347},{"type":21,"tag":111,"props":479,"children":481},{"class":113,"line":480},20,[482],{"type":21,"tag":111,"props":483,"children":484},{"style":118},[485],{"type":26,"value":356},{"type":21,"tag":111,"props":487,"children":489},{"class":113,"line":488},21,[490],{"type":21,"tag":111,"props":491,"children":492},{"style":118},[493],{"type":26,"value":494},"     * Replace the standard sync function with our new, websocket/socket.io based solution.\n",{"type":21,"tag":111,"props":496,"children":498},{"class":113,"line":497},22,[499],{"type":21,"tag":111,"props":500,"children":501},{"style":118},[502],{"type":26,"value":374},{"type":21,"tag":111,"props":504,"children":506},{"class":113,"line":505},23,[507,511,516,520,524,528,532,536,540,544,548],{"type":21,"tag":111,"props":508,"children":509},{"style":164},[510],{"type":26,"value":383},{"type":21,"tag":111,"props":512,"children":513},{"style":228},[514],{"type":26,"value":515},"sync",{"type":21,"tag":111,"props":517,"children":518},{"style":170},[519],{"type":26,"value":236},{"type":21,"tag":111,"props":521,"children":522},{"style":170},[523],{"type":26,"value":241},{"type":21,"tag":111,"props":525,"children":526},{"style":164},[527],{"type":26,"value":167},{"type":21,"tag":111,"props":529,"children":530},{"style":180},[531],{"type":26,"value":405},{"type":21,"tag":111,"props":533,"children":534},{"style":164},[535],{"type":26,"value":188},{"type":21,"tag":111,"props":537,"children":538},{"style":180},[539],{"type":26,"value":414},{"type":21,"tag":111,"props":541,"children":542},{"style":164},[543],{"type":26,"value":188},{"type":21,"tag":111,"props":545,"children":546},{"style":180},[547],{"type":26,"value":423},{"type":21,"tag":111,"props":549,"children":550},{"style":164},[551],{"type":26,"value":216},{"type":21,"tag":111,"props":553,"children":555},{"class":113,"line":554},24,[556,561,566,570,575,580],{"type":21,"tag":111,"props":557,"children":558},{"style":170},[559],{"type":26,"value":560},"        var",{"type":21,"tag":111,"props":562,"children":563},{"style":164},[564],{"type":26,"value":565}," opts ",{"type":21,"tag":111,"props":567,"children":568},{"style":170},[569],{"type":26,"value":303},{"type":21,"tag":111,"props":571,"children":572},{"style":164},[573],{"type":26,"value":574}," _.",{"type":21,"tag":111,"props":576,"children":577},{"style":228},[578],{"type":26,"value":579},"extend",{"type":21,"tag":111,"props":581,"children":582},{"style":164},[583],{"type":26,"value":584},"({}, options),\n",{"type":21,"tag":111,"props":586,"children":588},{"class":113,"line":587},25,[589,594,598,603,608],{"type":21,"tag":111,"props":590,"children":591},{"style":164},[592],{"type":26,"value":593},"            defer ",{"type":21,"tag":111,"props":595,"children":596},{"style":170},[597],{"type":26,"value":303},{"type":21,"tag":111,"props":599,"children":600},{"style":164},[601],{"type":26,"value":602}," $.",{"type":21,"tag":111,"props":604,"children":605},{"style":228},[606],{"type":26,"value":607},"Deferred",{"type":21,"tag":111,"props":609,"children":610},{"style":164},[611],{"type":26,"value":612},"(),\n",{"type":21,"tag":111,"props":614,"children":616},{"class":113,"line":615},26,[617,622,626,631,636],{"type":21,"tag":111,"props":618,"children":619},{"style":164},[620],{"type":26,"value":621},"            promise ",{"type":21,"tag":111,"props":623,"children":624},{"style":170},[625],{"type":26,"value":303},{"type":21,"tag":111,"props":627,"children":628},{"style":164},[629],{"type":26,"value":630}," defer.",{"type":21,"tag":111,"props":632,"children":633},{"style":228},[634],{"type":26,"value":635},"promise",{"type":21,"tag":111,"props":637,"children":638},{"style":164},[639],{"type":26,"value":612},{"type":21,"tag":111,"props":641,"children":643},{"class":113,"line":642},27,[644],{"type":21,"tag":111,"props":645,"children":646},{"style":164},[647],{"type":26,"value":648},"            namespace,\n",{"type":21,"tag":111,"props":650,"children":652},{"class":113,"line":651},28,[653],{"type":21,"tag":111,"props":654,"children":655},{"style":164},[656],{"type":26,"value":657},"            socket;\n",{"type":21,"tag":111,"props":659,"children":661},{"class":113,"line":660},29,[662],{"type":21,"tag":111,"props":663,"children":664},{"emptyLinePlaceholder":344},[665],{"type":26,"value":347},{"type":21,"tag":111,"props":667,"children":669},{"class":113,"line":668},30,[670,675,679,684,689,693,698,703,708,713,718,723,727,731,735,740,744,748,752,757,762],{"type":21,"tag":111,"props":671,"children":672},{"style":164},[673],{"type":26,"value":674},"        opts.url ",{"type":21,"tag":111,"props":676,"children":677},{"style":170},[678],{"type":26,"value":303},{"type":21,"tag":111,"props":680,"children":681},{"style":164},[682],{"type":26,"value":683}," (opts.url) ",{"type":21,"tag":111,"props":685,"children":686},{"style":170},[687],{"type":26,"value":688},"?",{"type":21,"tag":111,"props":690,"children":691},{"style":164},[692],{"type":26,"value":574},{"type":21,"tag":111,"props":694,"children":695},{"style":228},[696],{"type":26,"value":697},"result",{"type":21,"tag":111,"props":699,"children":700},{"style":164},[701],{"type":26,"value":702},"(opts, ",{"type":21,"tag":111,"props":704,"children":705},{"style":272},[706],{"type":26,"value":707},"'url'",{"type":21,"tag":111,"props":709,"children":710},{"style":164},[711],{"type":26,"value":712},") ",{"type":21,"tag":111,"props":714,"children":715},{"style":170},[716],{"type":26,"value":717},":",{"type":21,"tag":111,"props":719,"children":720},{"style":164},[721],{"type":26,"value":722}," (model.url) ",{"type":21,"tag":111,"props":724,"children":725},{"style":170},[726],{"type":26,"value":688},{"type":21,"tag":111,"props":728,"children":729},{"style":164},[730],{"type":26,"value":574},{"type":21,"tag":111,"props":732,"children":733},{"style":228},[734],{"type":26,"value":697},{"type":21,"tag":111,"props":736,"children":737},{"style":164},[738],{"type":26,"value":739},"(model, ",{"type":21,"tag":111,"props":741,"children":742},{"style":272},[743],{"type":26,"value":707},{"type":21,"tag":111,"props":745,"children":746},{"style":164},[747],{"type":26,"value":712},{"type":21,"tag":111,"props":749,"children":750},{"style":170},[751],{"type":26,"value":717},{"type":21,"tag":111,"props":753,"children":754},{"style":170},[755],{"type":26,"value":756}," void",{"type":21,"tag":111,"props":758,"children":759},{"style":311},[760],{"type":26,"value":761}," 0",{"type":21,"tag":111,"props":763,"children":764},{"style":164},[765],{"type":26,"value":766},";\n",{"type":21,"tag":111,"props":768,"children":770},{"class":113,"line":769},31,[771],{"type":21,"tag":111,"props":772,"children":773},{"style":118},[774],{"type":26,"value":775},"        // If no url property has been specified, throw an error, as per the standard Backbone sync\n",{"type":21,"tag":111,"props":777,"children":779},{"class":113,"line":778},32,[780,785,790,795,800,805],{"type":21,"tag":111,"props":781,"children":782},{"style":170},[783],{"type":26,"value":784},"        if",{"type":21,"tag":111,"props":786,"children":787},{"style":164},[788],{"type":26,"value":789}," (",{"type":21,"tag":111,"props":791,"children":792},{"style":170},[793],{"type":26,"value":794},"!",{"type":21,"tag":111,"props":796,"children":797},{"style":164},[798],{"type":26,"value":799},"opts.url) ",{"type":21,"tag":111,"props":801,"children":802},{"style":228},[803],{"type":26,"value":804},"urlError",{"type":21,"tag":111,"props":806,"children":807},{"style":164},[808],{"type":26,"value":809},"();\n",{"type":21,"tag":111,"props":811,"children":813},{"class":113,"line":812},33,[814],{"type":21,"tag":111,"props":815,"children":816},{"style":118},[817],{"type":26,"value":818},"        // Transform the url into a namespace\n",{"type":21,"tag":111,"props":820,"children":822},{"class":113,"line":821},34,[823,828,832,837,841,846,850,854,858],{"type":21,"tag":111,"props":824,"children":825},{"style":164},[826],{"type":26,"value":827},"        namespace ",{"type":21,"tag":111,"props":829,"children":830},{"style":170},[831],{"type":26,"value":303},{"type":21,"tag":111,"props":833,"children":834},{"style":164},[835],{"type":26,"value":836}," Backbone.Model.",{"type":21,"tag":111,"props":838,"children":839},{"style":311},[840],{"type":26,"value":314},{"type":21,"tag":111,"props":842,"children":843},{"style":164},[844],{"type":26,"value":845},".namespace.",{"type":21,"tag":111,"props":847,"children":848},{"style":228},[849],{"type":26,"value":446},{"type":21,"tag":111,"props":851,"children":852},{"style":164},[853],{"type":26,"value":167},{"type":21,"tag":111,"props":855,"children":856},{"style":311},[857],{"type":26,"value":455},{"type":21,"tag":111,"props":859,"children":860},{"style":164},[861],{"type":26,"value":862},", opts.url);\n",{"type":21,"tag":111,"props":864,"children":866},{"class":113,"line":865},35,[867],{"type":21,"tag":111,"props":868,"children":869},{"style":118},[870],{"type":26,"value":871},"        // Determine what data we're sending, and ensure id is present if we're performing a PATCH call\n",{"type":21,"tag":111,"props":873,"children":875},{"class":113,"line":874},36,[876,880,884,888,893,898,903,907,912,917,922,927,932,936],{"type":21,"tag":111,"props":877,"children":878},{"style":170},[879],{"type":26,"value":784},{"type":21,"tag":111,"props":881,"children":882},{"style":164},[883],{"type":26,"value":789},{"type":21,"tag":111,"props":885,"children":886},{"style":170},[887],{"type":26,"value":794},{"type":21,"tag":111,"props":889,"children":890},{"style":164},[891],{"type":26,"value":892},"opts.data ",{"type":21,"tag":111,"props":894,"children":895},{"style":170},[896],{"type":26,"value":897},"&&",{"type":21,"tag":111,"props":899,"children":900},{"style":164},[901],{"type":26,"value":902}," model) opts.data ",{"type":21,"tag":111,"props":904,"children":905},{"style":170},[906],{"type":26,"value":303},{"type":21,"tag":111,"props":908,"children":909},{"style":164},[910],{"type":26,"value":911}," opts.attrs ",{"type":21,"tag":111,"props":913,"children":914},{"style":170},[915],{"type":26,"value":916},"||",{"type":21,"tag":111,"props":918,"children":919},{"style":164},[920],{"type":26,"value":921}," model.",{"type":21,"tag":111,"props":923,"children":924},{"style":228},[925],{"type":26,"value":926},"toJSON",{"type":21,"tag":111,"props":928,"children":929},{"style":164},[930],{"type":26,"value":931},"(options) ",{"type":21,"tag":111,"props":933,"children":934},{"style":170},[935],{"type":26,"value":916},{"type":21,"tag":111,"props":937,"children":938},{"style":164},[939],{"type":26,"value":940}," {};\n",{"type":21,"tag":111,"props":942,"children":944},{"class":113,"line":943},37,[945,949,954,959,964,969,974,978,982,986,990,994,999,1003,1008,1013],{"type":21,"tag":111,"props":946,"children":947},{"style":170},[948],{"type":26,"value":784},{"type":21,"tag":111,"props":950,"children":951},{"style":164},[952],{"type":26,"value":953}," ((opts.data.id ",{"type":21,"tag":111,"props":955,"children":956},{"style":170},[957],{"type":26,"value":958},"===",{"type":21,"tag":111,"props":960,"children":961},{"style":311},[962],{"type":26,"value":963}," null",{"type":21,"tag":111,"props":965,"children":966},{"style":170},[967],{"type":26,"value":968}," ||",{"type":21,"tag":111,"props":970,"children":971},{"style":164},[972],{"type":26,"value":973}," opts.data.id ",{"type":21,"tag":111,"props":975,"children":976},{"style":170},[977],{"type":26,"value":958},{"type":21,"tag":111,"props":979,"children":980},{"style":170},[981],{"type":26,"value":756},{"type":21,"tag":111,"props":983,"children":984},{"style":311},[985],{"type":26,"value":761},{"type":21,"tag":111,"props":987,"children":988},{"style":164},[989],{"type":26,"value":712},{"type":21,"tag":111,"props":991,"children":992},{"style":170},[993],{"type":26,"value":897},{"type":21,"tag":111,"props":995,"children":996},{"style":164},[997],{"type":26,"value":998}," opts.patch ",{"type":21,"tag":111,"props":1000,"children":1001},{"style":170},[1002],{"type":26,"value":958},{"type":21,"tag":111,"props":1004,"children":1005},{"style":311},[1006],{"type":26,"value":1007}," true",{"type":21,"tag":111,"props":1009,"children":1010},{"style":170},[1011],{"type":26,"value":1012}," &&",{"type":21,"tag":111,"props":1014,"children":1015},{"style":164},[1016],{"type":26,"value":1017}," model){\n",{"type":21,"tag":111,"props":1019,"children":1021},{"class":113,"line":1020},38,[1022,1027,1031],{"type":21,"tag":111,"props":1023,"children":1024},{"style":164},[1025],{"type":26,"value":1026},"            opts.data.id ",{"type":21,"tag":111,"props":1028,"children":1029},{"style":170},[1030],{"type":26,"value":303},{"type":21,"tag":111,"props":1032,"children":1033},{"style":164},[1034],{"type":26,"value":1035}," model.id;\n",{"type":21,"tag":111,"props":1037,"children":1039},{"class":113,"line":1038},39,[1040],{"type":21,"tag":111,"props":1041,"children":1042},{"style":164},[1043],{"type":26,"value":1044},"        }\n",{"type":21,"tag":111,"props":1046,"children":1048},{"class":113,"line":1047},40,[1049],{"type":21,"tag":111,"props":1050,"children":1051},{"style":118},[1052],{"type":26,"value":1053},"        // Determine which websocket to use - set in options or on model\n",{"type":21,"tag":111,"props":1055,"children":1057},{"class":113,"line":1056},41,[1058,1063,1067,1072,1076],{"type":21,"tag":111,"props":1059,"children":1060},{"style":164},[1061],{"type":26,"value":1062},"        socket ",{"type":21,"tag":111,"props":1064,"children":1065},{"style":170},[1066],{"type":26,"value":303},{"type":21,"tag":111,"props":1068,"children":1069},{"style":164},[1070],{"type":26,"value":1071}," opts.socket ",{"type":21,"tag":111,"props":1073,"children":1074},{"style":170},[1075],{"type":26,"value":916},{"type":21,"tag":111,"props":1077,"children":1078},{"style":164},[1079],{"type":26,"value":1080}," model.socket;\n",{"type":21,"tag":111,"props":1082,"children":1084},{"class":113,"line":1083},42,[1085],{"type":21,"tag":111,"props":1086,"children":1087},{"style":118},[1088],{"type":26,"value":1089},"        // Add a listener for our namespaced method, and resolve or reject our deferred based on the response\n",{"type":21,"tag":111,"props":1091,"children":1093},{"class":113,"line":1092},43,[1094,1099,1104,1109,1114,1119,1123,1127,1132],{"type":21,"tag":111,"props":1095,"children":1096},{"style":164},[1097],{"type":26,"value":1098},"        socket.",{"type":21,"tag":111,"props":1100,"children":1101},{"style":228},[1102],{"type":26,"value":1103},"once",{"type":21,"tag":111,"props":1105,"children":1106},{"style":164},[1107],{"type":26,"value":1108},"(namespace",{"type":21,"tag":111,"props":1110,"children":1111},{"style":170},[1112],{"type":26,"value":1113},"+",{"type":21,"tag":111,"props":1115,"children":1116},{"style":164},[1117],{"type":26,"value":1118},"method, ",{"type":21,"tag":111,"props":1120,"children":1121},{"style":170},[1122],{"type":26,"value":173},{"type":21,"tag":111,"props":1124,"children":1125},{"style":164},[1126],{"type":26,"value":167},{"type":21,"tag":111,"props":1128,"children":1129},{"style":180},[1130],{"type":26,"value":1131},"res",{"type":21,"tag":111,"props":1133,"children":1134},{"style":164},[1135],{"type":26,"value":216},{"type":21,"tag":111,"props":1137,"children":1139},{"class":113,"line":1138},44,[1140,1145,1150,1154,1159,1163,1168],{"type":21,"tag":111,"props":1141,"children":1142},{"style":170},[1143],{"type":26,"value":1144},"            var",{"type":21,"tag":111,"props":1146,"children":1147},{"style":164},[1148],{"type":26,"value":1149}," success ",{"type":21,"tag":111,"props":1151,"children":1152},{"style":170},[1153],{"type":26,"value":303},{"type":21,"tag":111,"props":1155,"children":1156},{"style":164},[1157],{"type":26,"value":1158}," (res ",{"type":21,"tag":111,"props":1160,"children":1161},{"style":170},[1162],{"type":26,"value":897},{"type":21,"tag":111,"props":1164,"children":1165},{"style":164},[1166],{"type":26,"value":1167}," res.success); ",{"type":21,"tag":111,"props":1169,"children":1170},{"style":118},[1171],{"type":26,"value":1172},"// Expects server json response to contain a boolean 'success' field\n",{"type":21,"tag":111,"props":1174,"children":1176},{"class":113,"line":1175},45,[1177,1182],{"type":21,"tag":111,"props":1178,"children":1179},{"style":170},[1180],{"type":26,"value":1181},"            if",{"type":21,"tag":111,"props":1183,"children":1184},{"style":164},[1185],{"type":26,"value":1186}," (success)\n",{"type":21,"tag":111,"props":1188,"children":1190},{"class":113,"line":1189},46,[1191],{"type":21,"tag":111,"props":1192,"children":1193},{"style":164},[1194],{"type":26,"value":1195},"            {\n",{"type":21,"tag":111,"props":1197,"children":1199},{"class":113,"line":1198},47,[1200,1205,1210,1215,1220,1225],{"type":21,"tag":111,"props":1201,"children":1202},{"style":170},[1203],{"type":26,"value":1204},"                if",{"type":21,"tag":111,"props":1206,"children":1207},{"style":164},[1208],{"type":26,"value":1209}," (_.",{"type":21,"tag":111,"props":1211,"children":1212},{"style":228},[1213],{"type":26,"value":1214},"isFunction",{"type":21,"tag":111,"props":1216,"children":1217},{"style":164},[1218],{"type":26,"value":1219},"(options.success)) options.",{"type":21,"tag":111,"props":1221,"children":1222},{"style":228},[1223],{"type":26,"value":1224},"success",{"type":21,"tag":111,"props":1226,"children":1227},{"style":164},[1228],{"type":26,"value":1229},"(res);\n",{"type":21,"tag":111,"props":1231,"children":1233},{"class":113,"line":1232},48,[1234,1239,1244],{"type":21,"tag":111,"props":1235,"children":1236},{"style":164},[1237],{"type":26,"value":1238},"                defer.",{"type":21,"tag":111,"props":1240,"children":1241},{"style":228},[1242],{"type":26,"value":1243},"resolve",{"type":21,"tag":111,"props":1245,"children":1246},{"style":164},[1247],{"type":26,"value":1229},{"type":21,"tag":111,"props":1249,"children":1251},{"class":113,"line":1250},49,[1252,1257],{"type":21,"tag":111,"props":1253,"children":1254},{"style":170},[1255],{"type":26,"value":1256},"                return",{"type":21,"tag":111,"props":1258,"children":1259},{"style":164},[1260],{"type":26,"value":766},{"type":21,"tag":111,"props":1262,"children":1264},{"class":113,"line":1263},50,[1265],{"type":21,"tag":111,"props":1266,"children":1267},{"style":164},[1268],{"type":26,"value":1269},"            }\n",{"type":21,"tag":111,"props":1271,"children":1273},{"class":113,"line":1272},51,[1274,1278,1282,1286,1291,1296],{"type":21,"tag":111,"props":1275,"children":1276},{"style":170},[1277],{"type":26,"value":1181},{"type":21,"tag":111,"props":1279,"children":1280},{"style":164},[1281],{"type":26,"value":1209},{"type":21,"tag":111,"props":1283,"children":1284},{"style":228},[1285],{"type":26,"value":1214},{"type":21,"tag":111,"props":1287,"children":1288},{"style":164},[1289],{"type":26,"value":1290},"(options.error)) options.",{"type":21,"tag":111,"props":1292,"children":1293},{"style":228},[1294],{"type":26,"value":1295},"error",{"type":21,"tag":111,"props":1297,"children":1298},{"style":164},[1299],{"type":26,"value":1229},{"type":21,"tag":111,"props":1301,"children":1303},{"class":113,"line":1302},52,[1304,1309,1314],{"type":21,"tag":111,"props":1305,"children":1306},{"style":164},[1307],{"type":26,"value":1308},"            defer.",{"type":21,"tag":111,"props":1310,"children":1311},{"style":228},[1312],{"type":26,"value":1313},"reject",{"type":21,"tag":111,"props":1315,"children":1316},{"style":164},[1317],{"type":26,"value":1229},{"type":21,"tag":111,"props":1319,"children":1321},{"class":113,"line":1320},53,[1322],{"type":21,"tag":111,"props":1323,"children":1324},{"style":164},[1325],{"type":26,"value":1326},"        });\n",{"type":21,"tag":111,"props":1328,"children":1330},{"class":113,"line":1329},54,[1331],{"type":21,"tag":111,"props":1332,"children":1333},{"emptyLinePlaceholder":344},[1334],{"type":26,"value":347},{"type":21,"tag":111,"props":1336,"children":1338},{"class":113,"line":1337},55,[1339],{"type":21,"tag":111,"props":1340,"children":1341},{"style":118},[1342],{"type":26,"value":1343},"        // Emit our namespaced method and the model+opts data\n",{"type":21,"tag":111,"props":1345,"children":1347},{"class":113,"line":1346},56,[1348,1352,1357,1361,1365],{"type":21,"tag":111,"props":1349,"children":1350},{"style":164},[1351],{"type":26,"value":1098},{"type":21,"tag":111,"props":1353,"children":1354},{"style":228},[1355],{"type":26,"value":1356},"emit",{"type":21,"tag":111,"props":1358,"children":1359},{"style":164},[1360],{"type":26,"value":1108},{"type":21,"tag":111,"props":1362,"children":1363},{"style":170},[1364],{"type":26,"value":1113},{"type":21,"tag":111,"props":1366,"children":1367},{"style":164},[1368],{"type":26,"value":1369},"method, opts.data);\n",{"type":21,"tag":111,"props":1371,"children":1373},{"class":113,"line":1372},57,[1374],{"type":21,"tag":111,"props":1375,"children":1376},{"emptyLinePlaceholder":344},[1377],{"type":26,"value":347},{"type":21,"tag":111,"props":1379,"children":1381},{"class":113,"line":1380},58,[1382],{"type":21,"tag":111,"props":1383,"children":1384},{"style":118},[1385],{"type":26,"value":1386},"        // Trigger the request event on the model, as per backbone spec\n",{"type":21,"tag":111,"props":1388,"children":1390},{"class":113,"line":1389},59,[1391,1396,1401,1405,1410],{"type":21,"tag":111,"props":1392,"children":1393},{"style":164},[1394],{"type":26,"value":1395},"        model.",{"type":21,"tag":111,"props":1397,"children":1398},{"style":228},[1399],{"type":26,"value":1400},"trigger",{"type":21,"tag":111,"props":1402,"children":1403},{"style":164},[1404],{"type":26,"value":167},{"type":21,"tag":111,"props":1406,"children":1407},{"style":272},[1408],{"type":26,"value":1409},"'request'",{"type":21,"tag":111,"props":1411,"children":1412},{"style":164},[1413],{"type":26,"value":1414},", model, promise, opts);\n",{"type":21,"tag":111,"props":1416,"children":1418},{"class":113,"line":1417},60,[1419],{"type":21,"tag":111,"props":1420,"children":1421},{"style":118},[1422],{"type":26,"value":1423},"        // Return the promise for us to use as per usual (hanging .done blocks off, add to a .when, etc.)\n",{"type":21,"tag":111,"props":1425,"children":1427},{"class":113,"line":1426},61,[1428,1432],{"type":21,"tag":111,"props":1429,"children":1430},{"style":170},[1431],{"type":26,"value":436},{"type":21,"tag":111,"props":1433,"children":1434},{"style":164},[1435],{"type":26,"value":1436}," promise;\n",{"type":21,"tag":111,"props":1438,"children":1440},{"class":113,"line":1439},62,[1441],{"type":21,"tag":111,"props":1442,"children":1443},{"style":164},[1444],{"type":26,"value":469},{"type":21,"tag":111,"props":1446,"children":1448},{"class":113,"line":1447},63,[1449],{"type":21,"tag":111,"props":1450,"children":1451},{"emptyLinePlaceholder":344},[1452],{"type":26,"value":347},{"type":21,"tag":111,"props":1454,"children":1456},{"class":113,"line":1455},64,[1457],{"type":21,"tag":111,"props":1458,"children":1459},{"style":118},[1460],{"type":26,"value":356},{"type":21,"tag":111,"props":1462,"children":1464},{"class":113,"line":1463},65,[1465],{"type":21,"tag":111,"props":1466,"children":1467},{"style":118},[1468],{"type":26,"value":1469},"     * Break url apart to create namespace - every '/' save any pre/post-fixing the url will become a ':' indicating\n",{"type":21,"tag":111,"props":1471,"children":1473},{"class":113,"line":1472},66,[1474],{"type":21,"tag":111,"props":1475,"children":1476},{"style":118},[1477],{"type":26,"value":1478},"     * namespace - so a collection that maps to /api/posts will now have its events on the namespace\n",{"type":21,"tag":111,"props":1480,"children":1482},{"class":113,"line":1481},67,[1483],{"type":21,"tag":111,"props":1484,"children":1485},{"style":118},[1486],{"type":26,"value":1487},"     * api:posts: (ie. api:posts:create, api:posts:delete, etc.), and a model that maps to /api/posts/21\n",{"type":21,"tag":111,"props":1489,"children":1491},{"class":113,"line":1490},68,[1492],{"type":21,"tag":111,"props":1493,"children":1494},{"style":118},[1495],{"type":26,"value":1496},"     * will have events on api:posts:21: (ie. api:posts:21:update, api:posts:21:patch, etc.)\n",{"type":21,"tag":111,"props":1498,"children":1500},{"class":113,"line":1499},69,[1501,1506,1511,1516],{"type":21,"tag":111,"props":1502,"children":1503},{"style":118},[1504],{"type":26,"value":1505},"     * ",{"type":21,"tag":111,"props":1507,"children":1508},{"style":170},[1509],{"type":26,"value":1510},"@param",{"type":21,"tag":111,"props":1512,"children":1513},{"style":228},[1514],{"type":26,"value":1515}," {string=}",{"type":21,"tag":111,"props":1517,"children":1518},{"style":164},[1519],{"type":26,"value":1520}," url\n",{"type":21,"tag":111,"props":1522,"children":1524},{"class":113,"line":1523},70,[1525],{"type":21,"tag":111,"props":1526,"children":1527},{"style":118},[1528],{"type":26,"value":374},{"type":21,"tag":111,"props":1530,"children":1532},{"class":113,"line":1531},71,[1533,1538,1542,1546,1551,1555,1559,1563,1568],{"type":21,"tag":111,"props":1534,"children":1535},{"style":164},[1536],{"type":26,"value":1537},"    Backbone.Model.",{"type":21,"tag":111,"props":1539,"children":1540},{"style":311},[1541],{"type":26,"value":314},{"type":21,"tag":111,"props":1543,"children":1544},{"style":164},[1545],{"type":26,"value":62},{"type":21,"tag":111,"props":1547,"children":1548},{"style":228},[1549],{"type":26,"value":1550},"namespace",{"type":21,"tag":111,"props":1552,"children":1553},{"style":170},[1554],{"type":26,"value":236},{"type":21,"tag":111,"props":1556,"children":1557},{"style":170},[1558],{"type":26,"value":241},{"type":21,"tag":111,"props":1560,"children":1561},{"style":164},[1562],{"type":26,"value":167},{"type":21,"tag":111,"props":1564,"children":1565},{"style":180},[1566],{"type":26,"value":1567},"url",{"type":21,"tag":111,"props":1569,"children":1570},{"style":164},[1571],{"type":26,"value":216},{"type":21,"tag":111,"props":1573,"children":1575},{"class":113,"line":1574},72,[1576,1581,1585,1590,1594,1599,1603,1607],{"type":21,"tag":111,"props":1577,"children":1578},{"style":164},[1579],{"type":26,"value":1580},"        url ",{"type":21,"tag":111,"props":1582,"children":1583},{"style":170},[1584],{"type":26,"value":303},{"type":21,"tag":111,"props":1586,"children":1587},{"style":164},[1588],{"type":26,"value":1589}," url ",{"type":21,"tag":111,"props":1591,"children":1592},{"style":170},[1593],{"type":26,"value":916},{"type":21,"tag":111,"props":1595,"children":1596},{"style":311},[1597],{"type":26,"value":1598}," this",{"type":21,"tag":111,"props":1600,"children":1601},{"style":164},[1602],{"type":26,"value":62},{"type":21,"tag":111,"props":1604,"children":1605},{"style":228},[1606],{"type":26,"value":1567},{"type":21,"tag":111,"props":1608,"children":1609},{"style":164},[1610],{"type":26,"value":809},{"type":21,"tag":111,"props":1612,"children":1614},{"class":113,"line":1613},73,[1615,1619,1623,1628,1633,1638,1643,1648,1652,1656,1660,1665,1669,1673,1678],{"type":21,"tag":111,"props":1616,"children":1617},{"style":170},[1618],{"type":26,"value":436},{"type":21,"tag":111,"props":1620,"children":1621},{"style":164},[1622],{"type":26,"value":574},{"type":21,"tag":111,"props":1624,"children":1625},{"style":228},[1626],{"type":26,"value":1627},"trim",{"type":21,"tag":111,"props":1629,"children":1630},{"style":164},[1631],{"type":26,"value":1632},"(url, ",{"type":21,"tag":111,"props":1634,"children":1635},{"style":272},[1636],{"type":26,"value":1637},"'/'",{"type":21,"tag":111,"props":1639,"children":1640},{"style":164},[1641],{"type":26,"value":1642},").",{"type":21,"tag":111,"props":1644,"children":1645},{"style":228},[1646],{"type":26,"value":1647},"replace",{"type":21,"tag":111,"props":1649,"children":1650},{"style":164},[1651],{"type":26,"value":167},{"type":21,"tag":111,"props":1653,"children":1654},{"style":272},[1655],{"type":26,"value":1637},{"type":21,"tag":111,"props":1657,"children":1658},{"style":164},[1659],{"type":26,"value":188},{"type":21,"tag":111,"props":1661,"children":1662},{"style":272},[1663],{"type":26,"value":1664},"':'",{"type":21,"tag":111,"props":1666,"children":1667},{"style":164},[1668],{"type":26,"value":712},{"type":21,"tag":111,"props":1670,"children":1671},{"style":170},[1672],{"type":26,"value":1113},{"type":21,"tag":111,"props":1674,"children":1675},{"style":272},[1676],{"type":26,"value":1677}," \":\"",{"type":21,"tag":111,"props":1679,"children":1680},{"style":164},[1681],{"type":26,"value":766},{"type":21,"tag":111,"props":1683,"children":1685},{"class":113,"line":1684},74,[1686],{"type":21,"tag":111,"props":1687,"children":1688},{"style":164},[1689],{"type":26,"value":469},{"type":21,"tag":111,"props":1691,"children":1693},{"class":113,"line":1692},75,[1694],{"type":21,"tag":111,"props":1695,"children":1696},{"emptyLinePlaceholder":344},[1697],{"type":26,"value":347},{"type":21,"tag":111,"props":1699,"children":1701},{"class":113,"line":1700},76,[1702],{"type":21,"tag":111,"props":1703,"children":1704},{"style":118},[1705],{"type":26,"value":356},{"type":21,"tag":111,"props":1707,"children":1709},{"class":113,"line":1708},77,[1710],{"type":21,"tag":111,"props":1711,"children":1712},{"style":118},[1713],{"type":26,"value":1714},"     * Override EventEmitter.emit and SocketNamespace reference for socket.io to add a catch all case for the\n",{"type":21,"tag":111,"props":1716,"children":1718},{"class":113,"line":1717},78,[1719],{"type":21,"tag":111,"props":1720,"children":1721},{"style":118},[1722],{"type":26,"value":1723},"     * wildcard ('*') character. Now, socket.on('*') will catch any event, with the name of the caught event\n",{"type":21,"tag":111,"props":1725,"children":1727},{"class":113,"line":1726},79,[1728],{"type":21,"tag":111,"props":1729,"children":1730},{"style":118},[1731],{"type":26,"value":1732},"     * passed to the handler as the first argument.\n",{"type":21,"tag":111,"props":1734,"children":1736},{"class":113,"line":1735},80,[1737],{"type":21,"tag":111,"props":1738,"children":1739},{"style":118},[1740],{"type":26,"value":1741},"    */\n",{"type":21,"tag":111,"props":1743,"children":1745},{"class":113,"line":1744},81,[1746,1751,1755,1759,1763,1767,1771,1775,1780],{"type":21,"tag":111,"props":1747,"children":1748},{"style":164},[1749],{"type":26,"value":1750},"    io.EventEmitter.",{"type":21,"tag":111,"props":1752,"children":1753},{"style":311},[1754],{"type":26,"value":314},{"type":21,"tag":111,"props":1756,"children":1757},{"style":164},[1758],{"type":26,"value":62},{"type":21,"tag":111,"props":1760,"children":1761},{"style":228},[1762],{"type":26,"value":1356},{"type":21,"tag":111,"props":1764,"children":1765},{"style":170},[1766],{"type":26,"value":236},{"type":21,"tag":111,"props":1768,"children":1769},{"style":170},[1770],{"type":26,"value":241},{"type":21,"tag":111,"props":1772,"children":1773},{"style":164},[1774],{"type":26,"value":167},{"type":21,"tag":111,"props":1776,"children":1777},{"style":180},[1778],{"type":26,"value":1779},"name",{"type":21,"tag":111,"props":1781,"children":1782},{"style":164},[1783],{"type":26,"value":216},{"type":21,"tag":111,"props":1785,"children":1787},{"class":113,"line":1786},82,[1788,1792,1797,1801,1806,1810,1814,1819,1823,1827,1832,1836,1841],{"type":21,"tag":111,"props":1789,"children":1790},{"style":170},[1791],{"type":26,"value":560},{"type":21,"tag":111,"props":1793,"children":1794},{"style":164},[1795],{"type":26,"value":1796}," args ",{"type":21,"tag":111,"props":1798,"children":1799},{"style":170},[1800],{"type":26,"value":303},{"type":21,"tag":111,"props":1802,"children":1803},{"style":311},[1804],{"type":26,"value":1805}," Array",{"type":21,"tag":111,"props":1807,"children":1808},{"style":164},[1809],{"type":26,"value":62},{"type":21,"tag":111,"props":1811,"children":1812},{"style":311},[1813],{"type":26,"value":314},{"type":21,"tag":111,"props":1815,"children":1816},{"style":164},[1817],{"type":26,"value":1818},".slice.",{"type":21,"tag":111,"props":1820,"children":1821},{"style":228},[1822],{"type":26,"value":446},{"type":21,"tag":111,"props":1824,"children":1825},{"style":164},[1826],{"type":26,"value":167},{"type":21,"tag":111,"props":1828,"children":1829},{"style":311},[1830],{"type":26,"value":1831},"arguments",{"type":21,"tag":111,"props":1833,"children":1834},{"style":164},[1835],{"type":26,"value":188},{"type":21,"tag":111,"props":1837,"children":1838},{"style":311},[1839],{"type":26,"value":1840},"1",{"type":21,"tag":111,"props":1842,"children":1843},{"style":164},[1844],{"type":26,"value":280},{"type":21,"tag":111,"props":1846,"children":1848},{"class":113,"line":1847},83,[1849],{"type":21,"tag":111,"props":1850,"children":1851},{"emptyLinePlaceholder":344},[1852],{"type":26,"value":347},{"type":21,"tag":111,"props":1854,"children":1856},{"class":113,"line":1855},84,[1857,1862,1867,1871,1875,1880,1885,1890,1895],{"type":21,"tag":111,"props":1858,"children":1859},{"style":164},[1860],{"type":26,"value":1861},"        eventEmit.",{"type":21,"tag":111,"props":1863,"children":1864},{"style":228},[1865],{"type":26,"value":1866},"apply",{"type":21,"tag":111,"props":1868,"children":1869},{"style":164},[1870],{"type":26,"value":167},{"type":21,"tag":111,"props":1872,"children":1873},{"style":311},[1874],{"type":26,"value":455},{"type":21,"tag":111,"props":1876,"children":1877},{"style":164},[1878],{"type":26,"value":1879},", [",{"type":21,"tag":111,"props":1881,"children":1882},{"style":272},[1883],{"type":26,"value":1884},"'*'",{"type":21,"tag":111,"props":1886,"children":1887},{"style":164},[1888],{"type":26,"value":1889},", name].",{"type":21,"tag":111,"props":1891,"children":1892},{"style":228},[1893],{"type":26,"value":1894},"concat",{"type":21,"tag":111,"props":1896,"children":1897},{"style":164},[1898],{"type":26,"value":1899},"(args));\n",{"type":21,"tag":111,"props":1901,"children":1903},{"class":113,"line":1902},85,[1904,1908,1912,1916,1920,1925,1929],{"type":21,"tag":111,"props":1905,"children":1906},{"style":164},[1907],{"type":26,"value":1861},{"type":21,"tag":111,"props":1909,"children":1910},{"style":228},[1911],{"type":26,"value":1866},{"type":21,"tag":111,"props":1913,"children":1914},{"style":164},[1915],{"type":26,"value":167},{"type":21,"tag":111,"props":1917,"children":1918},{"style":311},[1919],{"type":26,"value":455},{"type":21,"tag":111,"props":1921,"children":1922},{"style":164},[1923],{"type":26,"value":1924},", [name].",{"type":21,"tag":111,"props":1926,"children":1927},{"style":228},[1928],{"type":26,"value":1894},{"type":21,"tag":111,"props":1930,"children":1931},{"style":164},[1932],{"type":26,"value":1899},{"type":21,"tag":111,"props":1934,"children":1936},{"class":113,"line":1935},86,[1937],{"type":21,"tag":111,"props":1938,"children":1939},{"style":164},[1940],{"type":26,"value":469},{"type":21,"tag":111,"props":1942,"children":1944},{"class":113,"line":1943},87,[1945,1950,1954,1959,1963,1967,1971],{"type":21,"tag":111,"props":1946,"children":1947},{"style":164},[1948],{"type":26,"value":1949},"    io.SocketNamespace.",{"type":21,"tag":111,"props":1951,"children":1952},{"style":311},[1953],{"type":26,"value":314},{"type":21,"tag":111,"props":1955,"children":1956},{"style":164},[1957],{"type":26,"value":1958},".$emit ",{"type":21,"tag":111,"props":1960,"children":1961},{"style":170},[1962],{"type":26,"value":303},{"type":21,"tag":111,"props":1964,"children":1965},{"style":164},[1966],{"type":26,"value":308},{"type":21,"tag":111,"props":1968,"children":1969},{"style":311},[1970],{"type":26,"value":314},{"type":21,"tag":111,"props":1972,"children":1973},{"style":164},[1974],{"type":26,"value":1975},".emit;\n",{"type":21,"tag":111,"props":1977,"children":1979},{"class":113,"line":1978},88,[1980],{"type":21,"tag":111,"props":1981,"children":1982},{"style":164},[1983],{"type":26,"value":1984},"})(Backbone, jQuery, _, io);\n",{"type":21,"tag":22,"props":1986,"children":1987},{},[1988],{"type":26,"value":1989},"So, let's start at the top (and the very bottom).",{"type":21,"tag":101,"props":1991,"children":1993},{"className":103,"code":1992,"language":105,"meta":8,"style":8},"(function(Backbone, $, _, io){\n    var urlError = function(){\n        throw new Error('A \"url\" property or function must be specified.');\n    },\n    eventEmit = io.EventEmitter.prototype.emit,\n    ajaxSync = Backbone.sync;\n\n    //... More code ...\n\n    })(Backbone, jQuery, _, io);\n",[1994],{"type":21,"tag":78,"props":1995,"children":1996},{"__ignoreMap":8},[1997,2044,2067,2094,2101,2125,2141,2148,2156,2163],{"type":21,"tag":111,"props":1998,"children":1999},{"class":113,"line":114},[2000,2004,2008,2012,2016,2020,2024,2028,2032,2036,2040],{"type":21,"tag":111,"props":2001,"children":2002},{"style":164},[2003],{"type":26,"value":167},{"type":21,"tag":111,"props":2005,"children":2006},{"style":170},[2007],{"type":26,"value":173},{"type":21,"tag":111,"props":2009,"children":2010},{"style":164},[2011],{"type":26,"value":167},{"type":21,"tag":111,"props":2013,"children":2014},{"style":180},[2015],{"type":26,"value":183},{"type":21,"tag":111,"props":2017,"children":2018},{"style":164},[2019],{"type":26,"value":188},{"type":21,"tag":111,"props":2021,"children":2022},{"style":180},[2023],{"type":26,"value":193},{"type":21,"tag":111,"props":2025,"children":2026},{"style":164},[2027],{"type":26,"value":188},{"type":21,"tag":111,"props":2029,"children":2030},{"style":180},[2031],{"type":26,"value":202},{"type":21,"tag":111,"props":2033,"children":2034},{"style":164},[2035],{"type":26,"value":188},{"type":21,"tag":111,"props":2037,"children":2038},{"style":180},[2039],{"type":26,"value":211},{"type":21,"tag":111,"props":2041,"children":2042},{"style":164},[2043],{"type":26,"value":216},{"type":21,"tag":111,"props":2045,"children":2046},{"class":113,"line":124},[2047,2051,2055,2059,2063],{"type":21,"tag":111,"props":2048,"children":2049},{"style":170},[2050],{"type":26,"value":225},{"type":21,"tag":111,"props":2052,"children":2053},{"style":228},[2054],{"type":26,"value":231},{"type":21,"tag":111,"props":2056,"children":2057},{"style":170},[2058],{"type":26,"value":236},{"type":21,"tag":111,"props":2060,"children":2061},{"style":170},[2062],{"type":26,"value":241},{"type":21,"tag":111,"props":2064,"children":2065},{"style":164},[2066],{"type":26,"value":246},{"type":21,"tag":111,"props":2068,"children":2069},{"class":113,"line":133},[2070,2074,2078,2082,2086,2090],{"type":21,"tag":111,"props":2071,"children":2072},{"style":170},[2073],{"type":26,"value":255},{"type":21,"tag":111,"props":2075,"children":2076},{"style":170},[2077],{"type":26,"value":260},{"type":21,"tag":111,"props":2079,"children":2080},{"style":228},[2081],{"type":26,"value":265},{"type":21,"tag":111,"props":2083,"children":2084},{"style":164},[2085],{"type":26,"value":167},{"type":21,"tag":111,"props":2087,"children":2088},{"style":272},[2089],{"type":26,"value":275},{"type":21,"tag":111,"props":2091,"children":2092},{"style":164},[2093],{"type":26,"value":280},{"type":21,"tag":111,"props":2095,"children":2096},{"class":113,"line":142},[2097],{"type":21,"tag":111,"props":2098,"children":2099},{"style":164},[2100],{"type":26,"value":289},{"type":21,"tag":111,"props":2102,"children":2103},{"class":113,"line":151},[2104,2109,2113,2117,2121],{"type":21,"tag":111,"props":2105,"children":2106},{"style":164},[2107],{"type":26,"value":2108},"    eventEmit ",{"type":21,"tag":111,"props":2110,"children":2111},{"style":170},[2112],{"type":26,"value":303},{"type":21,"tag":111,"props":2114,"children":2115},{"style":164},[2116],{"type":26,"value":308},{"type":21,"tag":111,"props":2118,"children":2119},{"style":311},[2120],{"type":26,"value":314},{"type":21,"tag":111,"props":2122,"children":2123},{"style":164},[2124],{"type":26,"value":319},{"type":21,"tag":111,"props":2126,"children":2127},{"class":113,"line":160},[2128,2133,2137],{"type":21,"tag":111,"props":2129,"children":2130},{"style":164},[2131],{"type":26,"value":2132},"    ajaxSync ",{"type":21,"tag":111,"props":2134,"children":2135},{"style":170},[2136],{"type":26,"value":303},{"type":21,"tag":111,"props":2138,"children":2139},{"style":164},[2140],{"type":26,"value":337},{"type":21,"tag":111,"props":2142,"children":2143},{"class":113,"line":219},[2144],{"type":21,"tag":111,"props":2145,"children":2146},{"emptyLinePlaceholder":344},[2147],{"type":26,"value":347},{"type":21,"tag":111,"props":2149,"children":2150},{"class":113,"line":249},[2151],{"type":21,"tag":111,"props":2152,"children":2153},{"style":118},[2154],{"type":26,"value":2155},"    //... More code ...\n",{"type":21,"tag":111,"props":2157,"children":2158},{"class":113,"line":283},[2159],{"type":21,"tag":111,"props":2160,"children":2161},{"emptyLinePlaceholder":344},[2162],{"type":26,"value":347},{"type":21,"tag":111,"props":2164,"children":2165},{"class":113,"line":292},[2166],{"type":21,"tag":111,"props":2167,"children":2168},{"style":164},[2169],{"type":26,"value":2170},"    })(Backbone, jQuery, _, io);\n",{"type":21,"tag":22,"props":2172,"children":2173},{},[2174],{"type":26,"value":2175},"We create a function expression, and feed it the expected globals - a reference to Backbone, jQuery, underscore and socket.io, in that order. At the top, we're reproducing backbone's standard urlError function, and then we're saving a reference to io's emit (more on that in a bit), and to the original, ajax-based sync.",{"type":21,"tag":101,"props":2177,"children":2179},{"className":103,"code":2178,"language":105,"meta":8,"style":8},"/**\n * Preserve the standard, jquery ajax based persistance method as ajaxSync.\n */\nBackbone.ajaxSync = function(method, model, options){\n    return ajaxSync.call(this, method, model, options);\n};\n",[2180],{"type":21,"tag":78,"props":2181,"children":2182},{"__ignoreMap":8},[2183,2190,2198,2205,2253,2281],{"type":21,"tag":111,"props":2184,"children":2185},{"class":113,"line":114},[2186],{"type":21,"tag":111,"props":2187,"children":2188},{"style":118},[2189],{"type":26,"value":121},{"type":21,"tag":111,"props":2191,"children":2192},{"class":113,"line":124},[2193],{"type":21,"tag":111,"props":2194,"children":2195},{"style":118},[2196],{"type":26,"value":2197}," * Preserve the standard, jquery ajax based persistance method as ajaxSync.\n",{"type":21,"tag":111,"props":2199,"children":2200},{"class":113,"line":133},[2201],{"type":21,"tag":111,"props":2202,"children":2203},{"style":118},[2204],{"type":26,"value":157},{"type":21,"tag":111,"props":2206,"children":2207},{"class":113,"line":142},[2208,2213,2217,2221,2225,2229,2233,2237,2241,2245,2249],{"type":21,"tag":111,"props":2209,"children":2210},{"style":164},[2211],{"type":26,"value":2212},"Backbone.",{"type":21,"tag":111,"props":2214,"children":2215},{"style":228},[2216],{"type":26,"value":388},{"type":21,"tag":111,"props":2218,"children":2219},{"style":170},[2220],{"type":26,"value":236},{"type":21,"tag":111,"props":2222,"children":2223},{"style":170},[2224],{"type":26,"value":241},{"type":21,"tag":111,"props":2226,"children":2227},{"style":164},[2228],{"type":26,"value":167},{"type":21,"tag":111,"props":2230,"children":2231},{"style":180},[2232],{"type":26,"value":405},{"type":21,"tag":111,"props":2234,"children":2235},{"style":164},[2236],{"type":26,"value":188},{"type":21,"tag":111,"props":2238,"children":2239},{"style":180},[2240],{"type":26,"value":414},{"type":21,"tag":111,"props":2242,"children":2243},{"style":164},[2244],{"type":26,"value":188},{"type":21,"tag":111,"props":2246,"children":2247},{"style":180},[2248],{"type":26,"value":423},{"type":21,"tag":111,"props":2250,"children":2251},{"style":164},[2252],{"type":26,"value":216},{"type":21,"tag":111,"props":2254,"children":2255},{"class":113,"line":151},[2256,2261,2265,2269,2273,2277],{"type":21,"tag":111,"props":2257,"children":2258},{"style":170},[2259],{"type":26,"value":2260},"    return",{"type":21,"tag":111,"props":2262,"children":2263},{"style":164},[2264],{"type":26,"value":441},{"type":21,"tag":111,"props":2266,"children":2267},{"style":228},[2268],{"type":26,"value":446},{"type":21,"tag":111,"props":2270,"children":2271},{"style":164},[2272],{"type":26,"value":167},{"type":21,"tag":111,"props":2274,"children":2275},{"style":311},[2276],{"type":26,"value":455},{"type":21,"tag":111,"props":2278,"children":2279},{"style":164},[2280],{"type":26,"value":460},{"type":21,"tag":111,"props":2282,"children":2283},{"class":113,"line":160},[2284],{"type":21,"tag":111,"props":2285,"children":2286},{"style":164},[2287],{"type":26,"value":2288},"};\n",{"type":21,"tag":22,"props":2290,"children":2291},{},[2292,2294,2299,2301,2306],{"type":26,"value":2293},"The comment says it all - we're preserving the standard ",{"type":21,"tag":78,"props":2295,"children":2297},{"className":2296},[],[2298],{"type":26,"value":515},{"type":26,"value":2300}," as ",{"type":21,"tag":78,"props":2302,"children":2304},{"className":2303},[],[2305],{"type":26,"value":388},{"type":26,"value":2307},", so if we want some collection or model to use the standard persistence method, we can.",{"type":21,"tag":22,"props":2309,"children":2310},{},[2311],{"type":26,"value":2312},"We can specify ajaxSync as our preferred sync method when we extend the collection:",{"type":21,"tag":101,"props":2314,"children":2316},{"className":103,"code":2315,"language":105,"meta":8,"style":8},"var collection = new (Backbone.Collection.extend({url:'/api/url', model:Backbone.Model, sync:Backbone.ajaxSync}))();\n",[2317],{"type":21,"tag":78,"props":2318,"children":2319},{"__ignoreMap":8},[2320],{"type":21,"tag":111,"props":2321,"children":2322},{"class":113,"line":114},[2323,2328,2333,2337,2341,2346,2350,2355,2360],{"type":21,"tag":111,"props":2324,"children":2325},{"style":170},[2326],{"type":26,"value":2327},"var",{"type":21,"tag":111,"props":2329,"children":2330},{"style":164},[2331],{"type":26,"value":2332}," collection ",{"type":21,"tag":111,"props":2334,"children":2335},{"style":170},[2336],{"type":26,"value":303},{"type":21,"tag":111,"props":2338,"children":2339},{"style":170},[2340],{"type":26,"value":260},{"type":21,"tag":111,"props":2342,"children":2343},{"style":164},[2344],{"type":26,"value":2345}," (Backbone.Collection.",{"type":21,"tag":111,"props":2347,"children":2348},{"style":228},[2349],{"type":26,"value":579},{"type":21,"tag":111,"props":2351,"children":2352},{"style":164},[2353],{"type":26,"value":2354},"({url:",{"type":21,"tag":111,"props":2356,"children":2357},{"style":272},[2358],{"type":26,"value":2359},"'/api/url'",{"type":21,"tag":111,"props":2361,"children":2362},{"style":164},[2363],{"type":26,"value":2364},", model:Backbone.Model, sync:Backbone.ajaxSync}))();\n",{"type":21,"tag":101,"props":2366,"children":2368},{"className":103,"code":2367,"language":105,"meta":8,"style":8},"/**\n * Replace the standard sync function with our new, websocket/socket.io based solution.\n */\nBackbone.sync = function(method, model, options){\n    var opts = _.extend({}, options),\n    defer = $.Deferred(),\n    promise = defer.promise(),\n    namespace,\n    socket;\n\n    opts.url = (opts.url) ? _.result(opts, 'url') : (model.url) ? _.result(model, 'url') : void 0;\n    // If no url property has been specified, throw an error, as per the standard Backbone sync\n    if (!opts.url) urlError();\n    // Transform the url into a namespace\n    namespace = Backbone.Model.prototype.namespace.call(this, opts.url);\n",[2369],{"type":21,"tag":78,"props":2370,"children":2371},{"__ignoreMap":8},[2372,2379,2387,2394,2441,2468,2492,2516,2524,2532,2539,2627,2635,2663,2671],{"type":21,"tag":111,"props":2373,"children":2374},{"class":113,"line":114},[2375],{"type":21,"tag":111,"props":2376,"children":2377},{"style":118},[2378],{"type":26,"value":121},{"type":21,"tag":111,"props":2380,"children":2381},{"class":113,"line":124},[2382],{"type":21,"tag":111,"props":2383,"children":2384},{"style":118},[2385],{"type":26,"value":2386}," * Replace the standard sync function with our new, websocket/socket.io based solution.\n",{"type":21,"tag":111,"props":2388,"children":2389},{"class":113,"line":133},[2390],{"type":21,"tag":111,"props":2391,"children":2392},{"style":118},[2393],{"type":26,"value":157},{"type":21,"tag":111,"props":2395,"children":2396},{"class":113,"line":142},[2397,2401,2405,2409,2413,2417,2421,2425,2429,2433,2437],{"type":21,"tag":111,"props":2398,"children":2399},{"style":164},[2400],{"type":26,"value":2212},{"type":21,"tag":111,"props":2402,"children":2403},{"style":228},[2404],{"type":26,"value":515},{"type":21,"tag":111,"props":2406,"children":2407},{"style":170},[2408],{"type":26,"value":236},{"type":21,"tag":111,"props":2410,"children":2411},{"style":170},[2412],{"type":26,"value":241},{"type":21,"tag":111,"props":2414,"children":2415},{"style":164},[2416],{"type":26,"value":167},{"type":21,"tag":111,"props":2418,"children":2419},{"style":180},[2420],{"type":26,"value":405},{"type":21,"tag":111,"props":2422,"children":2423},{"style":164},[2424],{"type":26,"value":188},{"type":21,"tag":111,"props":2426,"children":2427},{"style":180},[2428],{"type":26,"value":414},{"type":21,"tag":111,"props":2430,"children":2431},{"style":164},[2432],{"type":26,"value":188},{"type":21,"tag":111,"props":2434,"children":2435},{"style":180},[2436],{"type":26,"value":423},{"type":21,"tag":111,"props":2438,"children":2439},{"style":164},[2440],{"type":26,"value":216},{"type":21,"tag":111,"props":2442,"children":2443},{"class":113,"line":151},[2444,2448,2452,2456,2460,2464],{"type":21,"tag":111,"props":2445,"children":2446},{"style":170},[2447],{"type":26,"value":225},{"type":21,"tag":111,"props":2449,"children":2450},{"style":164},[2451],{"type":26,"value":565},{"type":21,"tag":111,"props":2453,"children":2454},{"style":170},[2455],{"type":26,"value":303},{"type":21,"tag":111,"props":2457,"children":2458},{"style":164},[2459],{"type":26,"value":574},{"type":21,"tag":111,"props":2461,"children":2462},{"style":228},[2463],{"type":26,"value":579},{"type":21,"tag":111,"props":2465,"children":2466},{"style":164},[2467],{"type":26,"value":584},{"type":21,"tag":111,"props":2469,"children":2470},{"class":113,"line":160},[2471,2476,2480,2484,2488],{"type":21,"tag":111,"props":2472,"children":2473},{"style":164},[2474],{"type":26,"value":2475},"    defer ",{"type":21,"tag":111,"props":2477,"children":2478},{"style":170},[2479],{"type":26,"value":303},{"type":21,"tag":111,"props":2481,"children":2482},{"style":164},[2483],{"type":26,"value":602},{"type":21,"tag":111,"props":2485,"children":2486},{"style":228},[2487],{"type":26,"value":607},{"type":21,"tag":111,"props":2489,"children":2490},{"style":164},[2491],{"type":26,"value":612},{"type":21,"tag":111,"props":2493,"children":2494},{"class":113,"line":219},[2495,2500,2504,2508,2512],{"type":21,"tag":111,"props":2496,"children":2497},{"style":164},[2498],{"type":26,"value":2499},"    promise ",{"type":21,"tag":111,"props":2501,"children":2502},{"style":170},[2503],{"type":26,"value":303},{"type":21,"tag":111,"props":2505,"children":2506},{"style":164},[2507],{"type":26,"value":630},{"type":21,"tag":111,"props":2509,"children":2510},{"style":228},[2511],{"type":26,"value":635},{"type":21,"tag":111,"props":2513,"children":2514},{"style":164},[2515],{"type":26,"value":612},{"type":21,"tag":111,"props":2517,"children":2518},{"class":113,"line":249},[2519],{"type":21,"tag":111,"props":2520,"children":2521},{"style":164},[2522],{"type":26,"value":2523},"    namespace,\n",{"type":21,"tag":111,"props":2525,"children":2526},{"class":113,"line":283},[2527],{"type":21,"tag":111,"props":2528,"children":2529},{"style":164},[2530],{"type":26,"value":2531},"    socket;\n",{"type":21,"tag":111,"props":2533,"children":2534},{"class":113,"line":292},[2535],{"type":21,"tag":111,"props":2536,"children":2537},{"emptyLinePlaceholder":344},[2538],{"type":26,"value":347},{"type":21,"tag":111,"props":2540,"children":2541},{"class":113,"line":322},[2542,2547,2551,2555,2559,2563,2567,2571,2575,2579,2583,2587,2591,2595,2599,2603,2607,2611,2615,2619,2623],{"type":21,"tag":111,"props":2543,"children":2544},{"style":164},[2545],{"type":26,"value":2546},"    opts.url ",{"type":21,"tag":111,"props":2548,"children":2549},{"style":170},[2550],{"type":26,"value":303},{"type":21,"tag":111,"props":2552,"children":2553},{"style":164},[2554],{"type":26,"value":683},{"type":21,"tag":111,"props":2556,"children":2557},{"style":170},[2558],{"type":26,"value":688},{"type":21,"tag":111,"props":2560,"children":2561},{"style":164},[2562],{"type":26,"value":574},{"type":21,"tag":111,"props":2564,"children":2565},{"style":228},[2566],{"type":26,"value":697},{"type":21,"tag":111,"props":2568,"children":2569},{"style":164},[2570],{"type":26,"value":702},{"type":21,"tag":111,"props":2572,"children":2573},{"style":272},[2574],{"type":26,"value":707},{"type":21,"tag":111,"props":2576,"children":2577},{"style":164},[2578],{"type":26,"value":712},{"type":21,"tag":111,"props":2580,"children":2581},{"style":170},[2582],{"type":26,"value":717},{"type":21,"tag":111,"props":2584,"children":2585},{"style":164},[2586],{"type":26,"value":722},{"type":21,"tag":111,"props":2588,"children":2589},{"style":170},[2590],{"type":26,"value":688},{"type":21,"tag":111,"props":2592,"children":2593},{"style":164},[2594],{"type":26,"value":574},{"type":21,"tag":111,"props":2596,"children":2597},{"style":228},[2598],{"type":26,"value":697},{"type":21,"tag":111,"props":2600,"children":2601},{"style":164},[2602],{"type":26,"value":739},{"type":21,"tag":111,"props":2604,"children":2605},{"style":272},[2606],{"type":26,"value":707},{"type":21,"tag":111,"props":2608,"children":2609},{"style":164},[2610],{"type":26,"value":712},{"type":21,"tag":111,"props":2612,"children":2613},{"style":170},[2614],{"type":26,"value":717},{"type":21,"tag":111,"props":2616,"children":2617},{"style":170},[2618],{"type":26,"value":756},{"type":21,"tag":111,"props":2620,"children":2621},{"style":311},[2622],{"type":26,"value":761},{"type":21,"tag":111,"props":2624,"children":2625},{"style":164},[2626],{"type":26,"value":766},{"type":21,"tag":111,"props":2628,"children":2629},{"class":113,"line":340},[2630],{"type":21,"tag":111,"props":2631,"children":2632},{"style":118},[2633],{"type":26,"value":2634},"    // If no url property has been specified, throw an error, as per the standard Backbone sync\n",{"type":21,"tag":111,"props":2636,"children":2637},{"class":113,"line":350},[2638,2643,2647,2651,2655,2659],{"type":21,"tag":111,"props":2639,"children":2640},{"style":170},[2641],{"type":26,"value":2642},"    if",{"type":21,"tag":111,"props":2644,"children":2645},{"style":164},[2646],{"type":26,"value":789},{"type":21,"tag":111,"props":2648,"children":2649},{"style":170},[2650],{"type":26,"value":794},{"type":21,"tag":111,"props":2652,"children":2653},{"style":164},[2654],{"type":26,"value":799},{"type":21,"tag":111,"props":2656,"children":2657},{"style":228},[2658],{"type":26,"value":804},{"type":21,"tag":111,"props":2660,"children":2661},{"style":164},[2662],{"type":26,"value":809},{"type":21,"tag":111,"props":2664,"children":2665},{"class":113,"line":359},[2666],{"type":21,"tag":111,"props":2667,"children":2668},{"style":118},[2669],{"type":26,"value":2670},"    // Transform the url into a namespace\n",{"type":21,"tag":111,"props":2672,"children":2673},{"class":113,"line":368},[2674,2679,2683,2687,2691,2695,2699,2703,2707],{"type":21,"tag":111,"props":2675,"children":2676},{"style":164},[2677],{"type":26,"value":2678},"    namespace ",{"type":21,"tag":111,"props":2680,"children":2681},{"style":170},[2682],{"type":26,"value":303},{"type":21,"tag":111,"props":2684,"children":2685},{"style":164},[2686],{"type":26,"value":836},{"type":21,"tag":111,"props":2688,"children":2689},{"style":311},[2690],{"type":26,"value":314},{"type":21,"tag":111,"props":2692,"children":2693},{"style":164},[2694],{"type":26,"value":845},{"type":21,"tag":111,"props":2696,"children":2697},{"style":228},[2698],{"type":26,"value":446},{"type":21,"tag":111,"props":2700,"children":2701},{"style":164},[2702],{"type":26,"value":167},{"type":21,"tag":111,"props":2704,"children":2705},{"style":311},[2706],{"type":26,"value":455},{"type":21,"tag":111,"props":2708,"children":2709},{"style":164},[2710],{"type":26,"value":862},{"type":21,"tag":22,"props":2712,"children":2713},{},[2714,2716,2722,2724,2729],{"type":26,"value":2715},"So, we ensure options is an object (potentially empty, if no options have been passed to us), create a jQuery Deferred object and it's promise, and declare namespace and socket for later use. Then, we attempt to determine the url, from the options first or, if not set there, from the model. Note the use of underscore's ",{"type":21,"tag":29,"props":2717,"children":2720},{"href":2718,"rel":2719},"http://underscorejs.org/#result",[33],[2721],{"type":26,"value":697},{"type":26,"value":2723}," function - ",{"type":21,"tag":78,"props":2725,"children":2727},{"className":2726},[],[2728],{"type":26,"value":1567},{"type":26,"value":2730}," can be either a function returning a string, or a string itself. If no url is found, we throw the backbone standard error. Otherwise, we translate the url into a namespace, using backbone conventions - more on that later.",{"type":21,"tag":101,"props":2732,"children":2734},{"className":103,"code":2733,"language":105,"meta":8,"style":8},"// Determine what data we're sending, and ensure id is present if we're performing a PATCH call\nif (!opts.data && model) opts.data = opts.attrs || model.toJSON(options) || {};\nif ((opts.data.id === null || opts.data.id === void 0) && opts.patch === true && model){\n    opts.data.id = model.id;\n}\n// Determine which websocket to use - set in options or on model\nsocket = opts.socket || model.socket;\n",[2735],{"type":21,"tag":78,"props":2736,"children":2737},{"__ignoreMap":8},[2738,2746,2806,2873,2889,2897,2905],{"type":21,"tag":111,"props":2739,"children":2740},{"class":113,"line":114},[2741],{"type":21,"tag":111,"props":2742,"children":2743},{"style":118},[2744],{"type":26,"value":2745},"// Determine what data we're sending, and ensure id is present if we're performing a PATCH call\n",{"type":21,"tag":111,"props":2747,"children":2748},{"class":113,"line":124},[2749,2754,2758,2762,2766,2770,2774,2778,2782,2786,2790,2794,2798,2802],{"type":21,"tag":111,"props":2750,"children":2751},{"style":170},[2752],{"type":26,"value":2753},"if",{"type":21,"tag":111,"props":2755,"children":2756},{"style":164},[2757],{"type":26,"value":789},{"type":21,"tag":111,"props":2759,"children":2760},{"style":170},[2761],{"type":26,"value":794},{"type":21,"tag":111,"props":2763,"children":2764},{"style":164},[2765],{"type":26,"value":892},{"type":21,"tag":111,"props":2767,"children":2768},{"style":170},[2769],{"type":26,"value":897},{"type":21,"tag":111,"props":2771,"children":2772},{"style":164},[2773],{"type":26,"value":902},{"type":21,"tag":111,"props":2775,"children":2776},{"style":170},[2777],{"type":26,"value":303},{"type":21,"tag":111,"props":2779,"children":2780},{"style":164},[2781],{"type":26,"value":911},{"type":21,"tag":111,"props":2783,"children":2784},{"style":170},[2785],{"type":26,"value":916},{"type":21,"tag":111,"props":2787,"children":2788},{"style":164},[2789],{"type":26,"value":921},{"type":21,"tag":111,"props":2791,"children":2792},{"style":228},[2793],{"type":26,"value":926},{"type":21,"tag":111,"props":2795,"children":2796},{"style":164},[2797],{"type":26,"value":931},{"type":21,"tag":111,"props":2799,"children":2800},{"style":170},[2801],{"type":26,"value":916},{"type":21,"tag":111,"props":2803,"children":2804},{"style":164},[2805],{"type":26,"value":940},{"type":21,"tag":111,"props":2807,"children":2808},{"class":113,"line":133},[2809,2813,2817,2821,2825,2829,2833,2837,2841,2845,2849,2853,2857,2861,2865,2869],{"type":21,"tag":111,"props":2810,"children":2811},{"style":170},[2812],{"type":26,"value":2753},{"type":21,"tag":111,"props":2814,"children":2815},{"style":164},[2816],{"type":26,"value":953},{"type":21,"tag":111,"props":2818,"children":2819},{"style":170},[2820],{"type":26,"value":958},{"type":21,"tag":111,"props":2822,"children":2823},{"style":311},[2824],{"type":26,"value":963},{"type":21,"tag":111,"props":2826,"children":2827},{"style":170},[2828],{"type":26,"value":968},{"type":21,"tag":111,"props":2830,"children":2831},{"style":164},[2832],{"type":26,"value":973},{"type":21,"tag":111,"props":2834,"children":2835},{"style":170},[2836],{"type":26,"value":958},{"type":21,"tag":111,"props":2838,"children":2839},{"style":170},[2840],{"type":26,"value":756},{"type":21,"tag":111,"props":2842,"children":2843},{"style":311},[2844],{"type":26,"value":761},{"type":21,"tag":111,"props":2846,"children":2847},{"style":164},[2848],{"type":26,"value":712},{"type":21,"tag":111,"props":2850,"children":2851},{"style":170},[2852],{"type":26,"value":897},{"type":21,"tag":111,"props":2854,"children":2855},{"style":164},[2856],{"type":26,"value":998},{"type":21,"tag":111,"props":2858,"children":2859},{"style":170},[2860],{"type":26,"value":958},{"type":21,"tag":111,"props":2862,"children":2863},{"style":311},[2864],{"type":26,"value":1007},{"type":21,"tag":111,"props":2866,"children":2867},{"style":170},[2868],{"type":26,"value":1012},{"type":21,"tag":111,"props":2870,"children":2871},{"style":164},[2872],{"type":26,"value":1017},{"type":21,"tag":111,"props":2874,"children":2875},{"class":113,"line":142},[2876,2881,2885],{"type":21,"tag":111,"props":2877,"children":2878},{"style":164},[2879],{"type":26,"value":2880},"    opts.data.id ",{"type":21,"tag":111,"props":2882,"children":2883},{"style":170},[2884],{"type":26,"value":303},{"type":21,"tag":111,"props":2886,"children":2887},{"style":164},[2888],{"type":26,"value":1035},{"type":21,"tag":111,"props":2890,"children":2891},{"class":113,"line":151},[2892],{"type":21,"tag":111,"props":2893,"children":2894},{"style":164},[2895],{"type":26,"value":2896},"}\n",{"type":21,"tag":111,"props":2898,"children":2899},{"class":113,"line":160},[2900],{"type":21,"tag":111,"props":2901,"children":2902},{"style":118},[2903],{"type":26,"value":2904},"// Determine which websocket to use - set in options or on model\n",{"type":21,"tag":111,"props":2906,"children":2907},{"class":113,"line":219},[2908,2913,2917,2921,2925],{"type":21,"tag":111,"props":2909,"children":2910},{"style":164},[2911],{"type":26,"value":2912},"socket ",{"type":21,"tag":111,"props":2914,"children":2915},{"style":170},[2916],{"type":26,"value":303},{"type":21,"tag":111,"props":2918,"children":2919},{"style":164},[2920],{"type":26,"value":1071},{"type":21,"tag":111,"props":2922,"children":2923},{"style":170},[2924],{"type":26,"value":916},{"type":21,"tag":111,"props":2926,"children":2927},{"style":164},[2928],{"type":26,"value":1080},{"type":21,"tag":22,"props":2930,"children":2931},{},[2932],{"type":26,"value":2933},"Note that we're deciding what socket to use in the same order as we determined url - first checking the options for the socket to have been passed in with this sync request, then checking the model. If you expect that socket may not be set on either, you may want to add a check at this point. If you intend to use a globally available socket, this is also where you'd add that as a default.",{"type":21,"tag":101,"props":2935,"children":2937},{"className":103,"code":2936,"language":105,"meta":8,"style":8}," // Add a listener for our namespaced method, and resolve or reject our deferred based on the response\nsocket.once(namespace+method, function(res){\n    var success = (res && res.success); // Expects server json response to contain a boolean 'success' field\n    if (success)\n    {\n        if (_.isFunction(options.success)) options.success(res);\n        defer.resolve(res);\n        return;\n    }\n    if (_.isFunction(options.error)) options.error(res);\n    defer.reject(res);\n});\n",[2938],{"type":21,"tag":78,"props":2939,"children":2940},{"__ignoreMap":8},[2941,2949,2989,3020,3031,3039,3066,3082,3093,3101,3128,3144],{"type":21,"tag":111,"props":2942,"children":2943},{"class":113,"line":114},[2944],{"type":21,"tag":111,"props":2945,"children":2946},{"style":118},[2947],{"type":26,"value":2948}," // Add a listener for our namespaced method, and resolve or reject our deferred based on the response\n",{"type":21,"tag":111,"props":2950,"children":2951},{"class":113,"line":124},[2952,2957,2961,2965,2969,2973,2977,2981,2985],{"type":21,"tag":111,"props":2953,"children":2954},{"style":164},[2955],{"type":26,"value":2956},"socket.",{"type":21,"tag":111,"props":2958,"children":2959},{"style":228},[2960],{"type":26,"value":1103},{"type":21,"tag":111,"props":2962,"children":2963},{"style":164},[2964],{"type":26,"value":1108},{"type":21,"tag":111,"props":2966,"children":2967},{"style":170},[2968],{"type":26,"value":1113},{"type":21,"tag":111,"props":2970,"children":2971},{"style":164},[2972],{"type":26,"value":1118},{"type":21,"tag":111,"props":2974,"children":2975},{"style":170},[2976],{"type":26,"value":173},{"type":21,"tag":111,"props":2978,"children":2979},{"style":164},[2980],{"type":26,"value":167},{"type":21,"tag":111,"props":2982,"children":2983},{"style":180},[2984],{"type":26,"value":1131},{"type":21,"tag":111,"props":2986,"children":2987},{"style":164},[2988],{"type":26,"value":216},{"type":21,"tag":111,"props":2990,"children":2991},{"class":113,"line":133},[2992,2996,3000,3004,3008,3012,3016],{"type":21,"tag":111,"props":2993,"children":2994},{"style":170},[2995],{"type":26,"value":225},{"type":21,"tag":111,"props":2997,"children":2998},{"style":164},[2999],{"type":26,"value":1149},{"type":21,"tag":111,"props":3001,"children":3002},{"style":170},[3003],{"type":26,"value":303},{"type":21,"tag":111,"props":3005,"children":3006},{"style":164},[3007],{"type":26,"value":1158},{"type":21,"tag":111,"props":3009,"children":3010},{"style":170},[3011],{"type":26,"value":897},{"type":21,"tag":111,"props":3013,"children":3014},{"style":164},[3015],{"type":26,"value":1167},{"type":21,"tag":111,"props":3017,"children":3018},{"style":118},[3019],{"type":26,"value":1172},{"type":21,"tag":111,"props":3021,"children":3022},{"class":113,"line":142},[3023,3027],{"type":21,"tag":111,"props":3024,"children":3025},{"style":170},[3026],{"type":26,"value":2642},{"type":21,"tag":111,"props":3028,"children":3029},{"style":164},[3030],{"type":26,"value":1186},{"type":21,"tag":111,"props":3032,"children":3033},{"class":113,"line":151},[3034],{"type":21,"tag":111,"props":3035,"children":3036},{"style":164},[3037],{"type":26,"value":3038},"    {\n",{"type":21,"tag":111,"props":3040,"children":3041},{"class":113,"line":160},[3042,3046,3050,3054,3058,3062],{"type":21,"tag":111,"props":3043,"children":3044},{"style":170},[3045],{"type":26,"value":784},{"type":21,"tag":111,"props":3047,"children":3048},{"style":164},[3049],{"type":26,"value":1209},{"type":21,"tag":111,"props":3051,"children":3052},{"style":228},[3053],{"type":26,"value":1214},{"type":21,"tag":111,"props":3055,"children":3056},{"style":164},[3057],{"type":26,"value":1219},{"type":21,"tag":111,"props":3059,"children":3060},{"style":228},[3061],{"type":26,"value":1224},{"type":21,"tag":111,"props":3063,"children":3064},{"style":164},[3065],{"type":26,"value":1229},{"type":21,"tag":111,"props":3067,"children":3068},{"class":113,"line":219},[3069,3074,3078],{"type":21,"tag":111,"props":3070,"children":3071},{"style":164},[3072],{"type":26,"value":3073},"        defer.",{"type":21,"tag":111,"props":3075,"children":3076},{"style":228},[3077],{"type":26,"value":1243},{"type":21,"tag":111,"props":3079,"children":3080},{"style":164},[3081],{"type":26,"value":1229},{"type":21,"tag":111,"props":3083,"children":3084},{"class":113,"line":249},[3085,3089],{"type":21,"tag":111,"props":3086,"children":3087},{"style":170},[3088],{"type":26,"value":436},{"type":21,"tag":111,"props":3090,"children":3091},{"style":164},[3092],{"type":26,"value":766},{"type":21,"tag":111,"props":3094,"children":3095},{"class":113,"line":283},[3096],{"type":21,"tag":111,"props":3097,"children":3098},{"style":164},[3099],{"type":26,"value":3100},"    }\n",{"type":21,"tag":111,"props":3102,"children":3103},{"class":113,"line":292},[3104,3108,3112,3116,3120,3124],{"type":21,"tag":111,"props":3105,"children":3106},{"style":170},[3107],{"type":26,"value":2642},{"type":21,"tag":111,"props":3109,"children":3110},{"style":164},[3111],{"type":26,"value":1209},{"type":21,"tag":111,"props":3113,"children":3114},{"style":228},[3115],{"type":26,"value":1214},{"type":21,"tag":111,"props":3117,"children":3118},{"style":164},[3119],{"type":26,"value":1290},{"type":21,"tag":111,"props":3121,"children":3122},{"style":228},[3123],{"type":26,"value":1295},{"type":21,"tag":111,"props":3125,"children":3126},{"style":164},[3127],{"type":26,"value":1229},{"type":21,"tag":111,"props":3129,"children":3130},{"class":113,"line":322},[3131,3136,3140],{"type":21,"tag":111,"props":3132,"children":3133},{"style":164},[3134],{"type":26,"value":3135},"    defer.",{"type":21,"tag":111,"props":3137,"children":3138},{"style":228},[3139],{"type":26,"value":1313},{"type":21,"tag":111,"props":3141,"children":3142},{"style":164},[3143],{"type":26,"value":1229},{"type":21,"tag":111,"props":3145,"children":3146},{"class":113,"line":340},[3147],{"type":21,"tag":111,"props":3148,"children":3149},{"style":164},[3150],{"type":26,"value":3151},"});\n",{"type":21,"tag":22,"props":3153,"children":3154},{},[3155,3157,3163,3165,3171,3173,3179],{"type":26,"value":3156},"Now, we add a listener for our namespace and request method. I'll go into more detail on this shortly, but the general form will look like ",{"type":21,"tag":78,"props":3158,"children":3160},{"className":3159},[],[3161],{"type":26,"value":3162},"url:components:method",{"type":26,"value":3164},", e.g. ",{"type":21,"tag":78,"props":3166,"children":3168},{"className":3167},[],[3169],{"type":26,"value":3170},"api:json:get",{"type":26,"value":3172}," or ",{"type":21,"tag":78,"props":3174,"children":3176},{"className":3175},[],[3177],{"type":26,"value":3178},"api:json:post",{"type":26,"value":62},{"type":21,"tag":22,"props":3181,"children":3182},{},[3183,3185,3190],{"type":26,"value":3184},"We expect the server to reply with json that will include a boolean ",{"type":21,"tag":78,"props":3186,"children":3188},{"className":3187},[],[3189],{"type":26,"value":1224},{"type":26,"value":3191}," field, and decide whether to trigger any success or error functions based on whether we've received a response and that response indicates success. We at this point also resolve or reject the promise we created earlier, and will return shortly.",{"type":21,"tag":22,"props":3193,"children":3194},{},[3195,3197,3203],{"type":26,"value":3196},"An earlier version of the code used the ",{"type":21,"tag":78,"props":3198,"children":3200},{"className":3199},[],[3201],{"type":26,"value":3202},"callback",{"type":26,"value":3204}," method of emitting, that looks like:",{"type":21,"tag":101,"props":3206,"children":3208},{"className":103,"code":3207,"language":105,"meta":8,"style":8},"socket.emit(namespace+method, opts.data, function(res){ // ... resolve promise ...  }\n",[3209],{"type":21,"tag":78,"props":3210,"children":3211},{"__ignoreMap":8},[3212],{"type":21,"tag":111,"props":3213,"children":3214},{"class":113,"line":114},[3215,3219,3223,3227,3231,3236,3240,3244,3248,3253],{"type":21,"tag":111,"props":3216,"children":3217},{"style":164},[3218],{"type":26,"value":2956},{"type":21,"tag":111,"props":3220,"children":3221},{"style":228},[3222],{"type":26,"value":1356},{"type":21,"tag":111,"props":3224,"children":3225},{"style":164},[3226],{"type":26,"value":1108},{"type":21,"tag":111,"props":3228,"children":3229},{"style":170},[3230],{"type":26,"value":1113},{"type":21,"tag":111,"props":3232,"children":3233},{"style":164},[3234],{"type":26,"value":3235},"method, opts.data, ",{"type":21,"tag":111,"props":3237,"children":3238},{"style":170},[3239],{"type":26,"value":173},{"type":21,"tag":111,"props":3241,"children":3242},{"style":164},[3243],{"type":26,"value":167},{"type":21,"tag":111,"props":3245,"children":3246},{"style":180},[3247],{"type":26,"value":1131},{"type":21,"tag":111,"props":3249,"children":3250},{"style":164},[3251],{"type":26,"value":3252},"){ ",{"type":21,"tag":111,"props":3254,"children":3255},{"style":118},[3256],{"type":26,"value":3257},"// ... resolve promise ...  }\n",{"type":21,"tag":22,"props":3259,"children":3260},{},[3261,3263,3270],{"type":26,"value":3262},"Why the change? This type of request emits a ",{"type":21,"tag":29,"props":3264,"children":3267},{"href":3265,"rel":3266},"https://github.com/automattic/socket.io-protocol",[33],[3268],{"type":26,"value":3269},"Data ACK packet",{"type":26,"value":3271},", which combines the ack packet (acknowledging the request) with the data expected of the response. It seems straightforward, but the protocol dictates that communication is BLOCKED until the ack packet is received, and now you've mandated that the ack packet not get sent until its ready to send the data along with it. Not an issue if you don't mind serving in order of request, and don't expect gathering the data to return to take long, but if you want to take advantage of async, out-of-order serving of requests, you need to use the approach we've discussed above, which sends an EVENT packet which can be responded to with an immediate ACK, and sent data later when it's ready.",{"type":21,"tag":101,"props":3273,"children":3275},{"className":103,"code":3274,"language":105,"meta":8,"style":8}," // Emit our namespaced method and the model+opts data\nsocket.emit(namespace+method, opts.data);\n\n// Trigger the request event on the model, as per backbone spec\nmodel.trigger('request', model, promise, opts);\n// Return the promise for us to use as per usual (hanging .done blocks off, add to a .when, etc.)\nreturn promise;\n",[3276],{"type":21,"tag":78,"props":3277,"children":3278},{"__ignoreMap":8},[3279,3287,3310,3317,3325,3349,3357],{"type":21,"tag":111,"props":3280,"children":3281},{"class":113,"line":114},[3282],{"type":21,"tag":111,"props":3283,"children":3284},{"style":118},[3285],{"type":26,"value":3286}," // Emit our namespaced method and the model+opts data\n",{"type":21,"tag":111,"props":3288,"children":3289},{"class":113,"line":124},[3290,3294,3298,3302,3306],{"type":21,"tag":111,"props":3291,"children":3292},{"style":164},[3293],{"type":26,"value":2956},{"type":21,"tag":111,"props":3295,"children":3296},{"style":228},[3297],{"type":26,"value":1356},{"type":21,"tag":111,"props":3299,"children":3300},{"style":164},[3301],{"type":26,"value":1108},{"type":21,"tag":111,"props":3303,"children":3304},{"style":170},[3305],{"type":26,"value":1113},{"type":21,"tag":111,"props":3307,"children":3308},{"style":164},[3309],{"type":26,"value":1369},{"type":21,"tag":111,"props":3311,"children":3312},{"class":113,"line":133},[3313],{"type":21,"tag":111,"props":3314,"children":3315},{"emptyLinePlaceholder":344},[3316],{"type":26,"value":347},{"type":21,"tag":111,"props":3318,"children":3319},{"class":113,"line":142},[3320],{"type":21,"tag":111,"props":3321,"children":3322},{"style":118},[3323],{"type":26,"value":3324},"// Trigger the request event on the model, as per backbone spec\n",{"type":21,"tag":111,"props":3326,"children":3327},{"class":113,"line":151},[3328,3333,3337,3341,3345],{"type":21,"tag":111,"props":3329,"children":3330},{"style":164},[3331],{"type":26,"value":3332},"model.",{"type":21,"tag":111,"props":3334,"children":3335},{"style":228},[3336],{"type":26,"value":1400},{"type":21,"tag":111,"props":3338,"children":3339},{"style":164},[3340],{"type":26,"value":167},{"type":21,"tag":111,"props":3342,"children":3343},{"style":272},[3344],{"type":26,"value":1409},{"type":21,"tag":111,"props":3346,"children":3347},{"style":164},[3348],{"type":26,"value":1414},{"type":21,"tag":111,"props":3350,"children":3351},{"class":113,"line":160},[3352],{"type":21,"tag":111,"props":3353,"children":3354},{"style":118},[3355],{"type":26,"value":3356},"// Return the promise for us to use as per usual (hanging .done blocks off, add to a .when, etc.)\n",{"type":21,"tag":111,"props":3358,"children":3359},{"class":113,"line":219},[3360,3365],{"type":21,"tag":111,"props":3361,"children":3362},{"style":170},[3363],{"type":26,"value":3364},"return",{"type":21,"tag":111,"props":3366,"children":3367},{"style":164},[3368],{"type":26,"value":1436},{"type":21,"tag":22,"props":3370,"children":3371},{},[3372],{"type":26,"value":3373},"Comments say it all for this one.",{"type":21,"tag":101,"props":3375,"children":3377},{"className":103,"code":3376,"language":105,"meta":8,"style":8},"/**\n * Break url apart to create namespace - every '/' save any pre/post-fixing the url will become a ':' indicating\n * namespace - so a collection that maps to /api/posts will now have its events on the namespace\n * api:posts: (ie. api:posts:create, api:posts:delete, etc.), and a model that maps to /api/posts/21\n * will have events on api:posts:21: (ie. api:posts:21:update, api:posts:21:patch, etc.)\n * @param {string=} url\n */\nBackbone.Model.prototype.namespace = function(url){\n    url = url || this.url();\n    return _.trim(url, '/').replace('/', ':') + \":\";\n};\n",[3378],{"type":21,"tag":78,"props":3379,"children":3380},{"__ignoreMap":8},[3381,3388,3396,3404,3412,3420,3440,3447,3487,3523,3586],{"type":21,"tag":111,"props":3382,"children":3383},{"class":113,"line":114},[3384],{"type":21,"tag":111,"props":3385,"children":3386},{"style":118},[3387],{"type":26,"value":121},{"type":21,"tag":111,"props":3389,"children":3390},{"class":113,"line":124},[3391],{"type":21,"tag":111,"props":3392,"children":3393},{"style":118},[3394],{"type":26,"value":3395}," * Break url apart to create namespace - every '/' save any pre/post-fixing the url will become a ':' indicating\n",{"type":21,"tag":111,"props":3397,"children":3398},{"class":113,"line":133},[3399],{"type":21,"tag":111,"props":3400,"children":3401},{"style":118},[3402],{"type":26,"value":3403}," * namespace - so a collection that maps to /api/posts will now have its events on the namespace\n",{"type":21,"tag":111,"props":3405,"children":3406},{"class":113,"line":142},[3407],{"type":21,"tag":111,"props":3408,"children":3409},{"style":118},[3410],{"type":26,"value":3411}," * api:posts: (ie. api:posts:create, api:posts:delete, etc.), and a model that maps to /api/posts/21\n",{"type":21,"tag":111,"props":3413,"children":3414},{"class":113,"line":151},[3415],{"type":21,"tag":111,"props":3416,"children":3417},{"style":118},[3418],{"type":26,"value":3419}," * will have events on api:posts:21: (ie. api:posts:21:update, api:posts:21:patch, etc.)\n",{"type":21,"tag":111,"props":3421,"children":3422},{"class":113,"line":160},[3423,3428,3432,3436],{"type":21,"tag":111,"props":3424,"children":3425},{"style":118},[3426],{"type":26,"value":3427}," * ",{"type":21,"tag":111,"props":3429,"children":3430},{"style":170},[3431],{"type":26,"value":1510},{"type":21,"tag":111,"props":3433,"children":3434},{"style":228},[3435],{"type":26,"value":1515},{"type":21,"tag":111,"props":3437,"children":3438},{"style":164},[3439],{"type":26,"value":1520},{"type":21,"tag":111,"props":3441,"children":3442},{"class":113,"line":219},[3443],{"type":21,"tag":111,"props":3444,"children":3445},{"style":118},[3446],{"type":26,"value":157},{"type":21,"tag":111,"props":3448,"children":3449},{"class":113,"line":249},[3450,3455,3459,3463,3467,3471,3475,3479,3483],{"type":21,"tag":111,"props":3451,"children":3452},{"style":164},[3453],{"type":26,"value":3454},"Backbone.Model.",{"type":21,"tag":111,"props":3456,"children":3457},{"style":311},[3458],{"type":26,"value":314},{"type":21,"tag":111,"props":3460,"children":3461},{"style":164},[3462],{"type":26,"value":62},{"type":21,"tag":111,"props":3464,"children":3465},{"style":228},[3466],{"type":26,"value":1550},{"type":21,"tag":111,"props":3468,"children":3469},{"style":170},[3470],{"type":26,"value":236},{"type":21,"tag":111,"props":3472,"children":3473},{"style":170},[3474],{"type":26,"value":241},{"type":21,"tag":111,"props":3476,"children":3477},{"style":164},[3478],{"type":26,"value":167},{"type":21,"tag":111,"props":3480,"children":3481},{"style":180},[3482],{"type":26,"value":1567},{"type":21,"tag":111,"props":3484,"children":3485},{"style":164},[3486],{"type":26,"value":216},{"type":21,"tag":111,"props":3488,"children":3489},{"class":113,"line":283},[3490,3495,3499,3503,3507,3511,3515,3519],{"type":21,"tag":111,"props":3491,"children":3492},{"style":164},[3493],{"type":26,"value":3494},"    url ",{"type":21,"tag":111,"props":3496,"children":3497},{"style":170},[3498],{"type":26,"value":303},{"type":21,"tag":111,"props":3500,"children":3501},{"style":164},[3502],{"type":26,"value":1589},{"type":21,"tag":111,"props":3504,"children":3505},{"style":170},[3506],{"type":26,"value":916},{"type":21,"tag":111,"props":3508,"children":3509},{"style":311},[3510],{"type":26,"value":1598},{"type":21,"tag":111,"props":3512,"children":3513},{"style":164},[3514],{"type":26,"value":62},{"type":21,"tag":111,"props":3516,"children":3517},{"style":228},[3518],{"type":26,"value":1567},{"type":21,"tag":111,"props":3520,"children":3521},{"style":164},[3522],{"type":26,"value":809},{"type":21,"tag":111,"props":3524,"children":3525},{"class":113,"line":292},[3526,3530,3534,3538,3542,3546,3550,3554,3558,3562,3566,3570,3574,3578,3582],{"type":21,"tag":111,"props":3527,"children":3528},{"style":170},[3529],{"type":26,"value":2260},{"type":21,"tag":111,"props":3531,"children":3532},{"style":164},[3533],{"type":26,"value":574},{"type":21,"tag":111,"props":3535,"children":3536},{"style":228},[3537],{"type":26,"value":1627},{"type":21,"tag":111,"props":3539,"children":3540},{"style":164},[3541],{"type":26,"value":1632},{"type":21,"tag":111,"props":3543,"children":3544},{"style":272},[3545],{"type":26,"value":1637},{"type":21,"tag":111,"props":3547,"children":3548},{"style":164},[3549],{"type":26,"value":1642},{"type":21,"tag":111,"props":3551,"children":3552},{"style":228},[3553],{"type":26,"value":1647},{"type":21,"tag":111,"props":3555,"children":3556},{"style":164},[3557],{"type":26,"value":167},{"type":21,"tag":111,"props":3559,"children":3560},{"style":272},[3561],{"type":26,"value":1637},{"type":21,"tag":111,"props":3563,"children":3564},{"style":164},[3565],{"type":26,"value":188},{"type":21,"tag":111,"props":3567,"children":3568},{"style":272},[3569],{"type":26,"value":1664},{"type":21,"tag":111,"props":3571,"children":3572},{"style":164},[3573],{"type":26,"value":712},{"type":21,"tag":111,"props":3575,"children":3576},{"style":170},[3577],{"type":26,"value":1113},{"type":21,"tag":111,"props":3579,"children":3580},{"style":272},[3581],{"type":26,"value":1677},{"type":21,"tag":111,"props":3583,"children":3584},{"style":164},[3585],{"type":26,"value":766},{"type":21,"tag":111,"props":3587,"children":3588},{"class":113,"line":322},[3589],{"type":21,"tag":111,"props":3590,"children":3591},{"style":164},[3592],{"type":26,"value":2288},{"type":21,"tag":22,"props":3594,"children":3595},{},[3596],{"type":26,"value":3597},"This one too, I think. Note, this isn't a required part of implementing socket.io - it just nicely mirros the style of events that backbone uses internally.",{"type":21,"tag":101,"props":3599,"children":3601},{"className":103,"code":3600,"language":105,"meta":8,"style":8},"/**\n * Override EventEmitter.emit and SocketNamespace reference for socket.io to add a catch all case for the\n * wildcard ('*') character. Now, socket.on('*') will catch any event, with the name of the caught event\n * passed to the handler as the first argument.\n */\nio.EventEmitter.prototype.emit = function(name){\n    var args = Array.prototype.slice.call(arguments, 1);\n\n    eventEmit.apply(this, ['*', name].concat(args));\n    eventEmit.apply(this, [name].concat(args));\n};\nio.SocketNamespace.prototype.$emit = io.EventEmitter.prototype.emit;\n",[3602],{"type":21,"tag":78,"props":3603,"children":3604},{"__ignoreMap":8},[3605,3612,3620,3628,3636,3643,3683,3738,3745,3785,3816,3823],{"type":21,"tag":111,"props":3606,"children":3607},{"class":113,"line":114},[3608],{"type":21,"tag":111,"props":3609,"children":3610},{"style":118},[3611],{"type":26,"value":121},{"type":21,"tag":111,"props":3613,"children":3614},{"class":113,"line":124},[3615],{"type":21,"tag":111,"props":3616,"children":3617},{"style":118},[3618],{"type":26,"value":3619}," * Override EventEmitter.emit and SocketNamespace reference for socket.io to add a catch all case for the\n",{"type":21,"tag":111,"props":3621,"children":3622},{"class":113,"line":133},[3623],{"type":21,"tag":111,"props":3624,"children":3625},{"style":118},[3626],{"type":26,"value":3627}," * wildcard ('*') character. Now, socket.on('*') will catch any event, with the name of the caught event\n",{"type":21,"tag":111,"props":3629,"children":3630},{"class":113,"line":142},[3631],{"type":21,"tag":111,"props":3632,"children":3633},{"style":118},[3634],{"type":26,"value":3635}," * passed to the handler as the first argument.\n",{"type":21,"tag":111,"props":3637,"children":3638},{"class":113,"line":151},[3639],{"type":21,"tag":111,"props":3640,"children":3641},{"style":118},[3642],{"type":26,"value":157},{"type":21,"tag":111,"props":3644,"children":3645},{"class":113,"line":160},[3646,3651,3655,3659,3663,3667,3671,3675,3679],{"type":21,"tag":111,"props":3647,"children":3648},{"style":164},[3649],{"type":26,"value":3650},"io.EventEmitter.",{"type":21,"tag":111,"props":3652,"children":3653},{"style":311},[3654],{"type":26,"value":314},{"type":21,"tag":111,"props":3656,"children":3657},{"style":164},[3658],{"type":26,"value":62},{"type":21,"tag":111,"props":3660,"children":3661},{"style":228},[3662],{"type":26,"value":1356},{"type":21,"tag":111,"props":3664,"children":3665},{"style":170},[3666],{"type":26,"value":236},{"type":21,"tag":111,"props":3668,"children":3669},{"style":170},[3670],{"type":26,"value":241},{"type":21,"tag":111,"props":3672,"children":3673},{"style":164},[3674],{"type":26,"value":167},{"type":21,"tag":111,"props":3676,"children":3677},{"style":180},[3678],{"type":26,"value":1779},{"type":21,"tag":111,"props":3680,"children":3681},{"style":164},[3682],{"type":26,"value":216},{"type":21,"tag":111,"props":3684,"children":3685},{"class":113,"line":219},[3686,3690,3694,3698,3702,3706,3710,3714,3718,3722,3726,3730,3734],{"type":21,"tag":111,"props":3687,"children":3688},{"style":170},[3689],{"type":26,"value":225},{"type":21,"tag":111,"props":3691,"children":3692},{"style":164},[3693],{"type":26,"value":1796},{"type":21,"tag":111,"props":3695,"children":3696},{"style":170},[3697],{"type":26,"value":303},{"type":21,"tag":111,"props":3699,"children":3700},{"style":311},[3701],{"type":26,"value":1805},{"type":21,"tag":111,"props":3703,"children":3704},{"style":164},[3705],{"type":26,"value":62},{"type":21,"tag":111,"props":3707,"children":3708},{"style":311},[3709],{"type":26,"value":314},{"type":21,"tag":111,"props":3711,"children":3712},{"style":164},[3713],{"type":26,"value":1818},{"type":21,"tag":111,"props":3715,"children":3716},{"style":228},[3717],{"type":26,"value":446},{"type":21,"tag":111,"props":3719,"children":3720},{"style":164},[3721],{"type":26,"value":167},{"type":21,"tag":111,"props":3723,"children":3724},{"style":311},[3725],{"type":26,"value":1831},{"type":21,"tag":111,"props":3727,"children":3728},{"style":164},[3729],{"type":26,"value":188},{"type":21,"tag":111,"props":3731,"children":3732},{"style":311},[3733],{"type":26,"value":1840},{"type":21,"tag":111,"props":3735,"children":3736},{"style":164},[3737],{"type":26,"value":280},{"type":21,"tag":111,"props":3739,"children":3740},{"class":113,"line":249},[3741],{"type":21,"tag":111,"props":3742,"children":3743},{"emptyLinePlaceholder":344},[3744],{"type":26,"value":347},{"type":21,"tag":111,"props":3746,"children":3747},{"class":113,"line":283},[3748,3753,3757,3761,3765,3769,3773,3777,3781],{"type":21,"tag":111,"props":3749,"children":3750},{"style":164},[3751],{"type":26,"value":3752},"    eventEmit.",{"type":21,"tag":111,"props":3754,"children":3755},{"style":228},[3756],{"type":26,"value":1866},{"type":21,"tag":111,"props":3758,"children":3759},{"style":164},[3760],{"type":26,"value":167},{"type":21,"tag":111,"props":3762,"children":3763},{"style":311},[3764],{"type":26,"value":455},{"type":21,"tag":111,"props":3766,"children":3767},{"style":164},[3768],{"type":26,"value":1879},{"type":21,"tag":111,"props":3770,"children":3771},{"style":272},[3772],{"type":26,"value":1884},{"type":21,"tag":111,"props":3774,"children":3775},{"style":164},[3776],{"type":26,"value":1889},{"type":21,"tag":111,"props":3778,"children":3779},{"style":228},[3780],{"type":26,"value":1894},{"type":21,"tag":111,"props":3782,"children":3783},{"style":164},[3784],{"type":26,"value":1899},{"type":21,"tag":111,"props":3786,"children":3787},{"class":113,"line":292},[3788,3792,3796,3800,3804,3808,3812],{"type":21,"tag":111,"props":3789,"children":3790},{"style":164},[3791],{"type":26,"value":3752},{"type":21,"tag":111,"props":3793,"children":3794},{"style":228},[3795],{"type":26,"value":1866},{"type":21,"tag":111,"props":3797,"children":3798},{"style":164},[3799],{"type":26,"value":167},{"type":21,"tag":111,"props":3801,"children":3802},{"style":311},[3803],{"type":26,"value":455},{"type":21,"tag":111,"props":3805,"children":3806},{"style":164},[3807],{"type":26,"value":1924},{"type":21,"tag":111,"props":3809,"children":3810},{"style":228},[3811],{"type":26,"value":1894},{"type":21,"tag":111,"props":3813,"children":3814},{"style":164},[3815],{"type":26,"value":1899},{"type":21,"tag":111,"props":3817,"children":3818},{"class":113,"line":322},[3819],{"type":21,"tag":111,"props":3820,"children":3821},{"style":164},[3822],{"type":26,"value":2288},{"type":21,"tag":111,"props":3824,"children":3825},{"class":113,"line":340},[3826,3831,3835,3839,3843,3847,3851],{"type":21,"tag":111,"props":3827,"children":3828},{"style":164},[3829],{"type":26,"value":3830},"io.SocketNamespace.",{"type":21,"tag":111,"props":3832,"children":3833},{"style":311},[3834],{"type":26,"value":314},{"type":21,"tag":111,"props":3836,"children":3837},{"style":164},[3838],{"type":26,"value":1958},{"type":21,"tag":111,"props":3840,"children":3841},{"style":170},[3842],{"type":26,"value":303},{"type":21,"tag":111,"props":3844,"children":3845},{"style":164},[3846],{"type":26,"value":308},{"type":21,"tag":111,"props":3848,"children":3849},{"style":311},[3850],{"type":26,"value":314},{"type":21,"tag":111,"props":3852,"children":3853},{"style":164},[3854],{"type":26,"value":1975},{"type":21,"tag":22,"props":3856,"children":3857},{},[3858,3860,3865],{"type":26,"value":3859},"And here's the reason why we saved the io ",{"type":21,"tag":78,"props":3861,"children":3863},{"className":3862},[],[3864],{"type":26,"value":1356},{"type":26,"value":3866}," function earlier - this little shim sits in front of the standard emit and allows us to add a wildcard catch-all for events on a socket.",{"type":21,"tag":22,"props":3868,"children":3869},{},[3870],{"type":26,"value":3871},"And that's all folks! Of course, you'll need to support your implementation on the server-side - how exactly you go about that will depend on the language and library your using.",{"type":21,"tag":22,"props":3873,"children":3874},{},[3875],{"type":26,"value":3876},"I do have one more goodie for you, though - here's a version of the above tailored for those of you using Marionette:",{"type":21,"tag":101,"props":3878,"children":3880},{"className":103,"code":3879,"language":105,"meta":8,"style":8},"/**\n * Copyright (c) Christopher Keefer. All Rights Reserved.\n *\n * Overrides the default transport for Backbone syncing to use websockets via socket.io. Includes marionette     \n * convenience code, specifically for sending socket-related events along the global event aggregator.\n */\n(function(app, Backbone, Marionette, $, _, io){\n    var urlError = function(){\n        throw new Error('A \"url\" property or function must be specified.');\n    },\n        eventEmit = io.EventEmitter.prototype.emit,\n        ajaxSync = Backbone.sync;\n\n    /**\n     * Preserve the standard, jquery ajax based persistance method as ajaxSync.\n     */\n    Backbone.ajaxSync = function(method, model, options){\n        return ajaxSync.call(this, method, model, options);\n    };\n\n    /**\n     * Replace the standard sync function with our new, websocket/socket.io based solution.\n     */\n    Backbone.sync = function(method, model, options){\n        var opts = _.extend({}, options),\n            defer = $.Deferred(),\n            promise = defer.promise(),\n            namespace,\n            socket;\n\n        opts.url = (opts.url) ? _.result(opts, 'url') : (model.url) ? _.result(model, 'url') : void 0;\n        // If no url property has been specified, throw an error, as per the standard Backbone sync\n        if (!opts.url) urlError();\n        namespace = Backbone.Model.prototype.namespace.call(this, opts.url);\n        // Determine what data we're sending, and ensure id is present if we're performing a PATCH call\n        if (!opts.data && model) opts.data = opts.attrs || model.toJSON(options) || {};\n        if ((opts.data.id === null || opts.data.id === void 0) && opts.patch === true && model){\n            opts.data.id = model.id;\n        }\n        // Determine which websocket to use - set in options, on model, or on global app\n        socket = opts.socket || model.socket || app.socket;\n        // Trigger the app event aggregator for interested listeners to know we're about to request data via websocket\n        app.vent.trigger('backbone:request', namespace);\n        // Add a listener for our namespaced method, and resolve or reject our deferred based on the response\n        socket.once(namespace+method, function(res){\n            var success = (res && res.success);\n            // Trigger the app event aggregator to indicate we've received a return from the server, and success\n            app.vent.trigger('backbone:receive', namespace, success);\n            if (success)\n            {\n                if (_.isFunction(options.success)) options.success(res);\n                defer.resolve(res);\n                return;\n            }\n            if (_.isFunction(options.error)) options.error(res);\n            defer.reject(res);\n        });\n\n        // Emit our namespaced method and the model+opts data\n        socket.emit(namespace+method, opts.data);\n\n        // Trigger the request event on the model, as per backbone spec\n        model.trigger('request', model, promise, opts);\n        // Return the promise for us to use as per usual (hanging .done blocks off, add to a .when, etc.)\n        return promise;\n    };\n\n    /**\n     * Break url apart to create namespace - every '/' save any pre/post-fixing the url will become a ':' indicating\n     * namespace - so a collection that maps to /api/posts will now have its events on the namespace\n     * api:posts: (ie. api:posts:create, api:posts:delete, etc.), and a model that maps to /api/posts/21\n     * will have events on api:posts:21: (ie. api:posts:21:update, api:posts:21:patch, etc.)\n     * @param {string=} url\n     */\n    Backbone.Model.prototype.namespace = function(url){\n        url = url || this.url();\n        return _.trim(url, '/').replace('/', ':') + \":\";\n    };\n\n    /**\n     * Override EventEmitter.emit and SocketNamespace reference for socket.io to add a catch all case for the\n     * wildcard ('*') character. Now, socket.on('*') will catch any event, with the name of the caught event\n     * passed to the handler as the first argument.\n    */\n    io.EventEmitter.prototype.emit = function(name){\n        var args = Array.prototype.slice.call(arguments, 1);\n\n        eventEmit.apply(this, ['*', name].concat(args));\n        eventEmit.apply(this, [name].concat(args));\n    };\n    io.SocketNamespace.prototype.$emit = io.EventEmitter.prototype.emit;\n\n    /**\n     * Create a socket io instance that will echo all events into the application event aggregator, so that\n     * collections, models, etc. can listen on app.vent for their events.\n     * @param {string=} url\n     * @constructor\n     */\n    Marionette.Application.prototype.SocketIO = function(url){\n        var socket = io.connect(url, {\n            transports:['websocket']\n        });\n\n        /**\n         * On any event from the server, trigger it on the app event aggregator. The first\n         * argument will always be the name of the event.\n         */\n        socket.on('*', function(){\n            var args = Array.prototype.slice.call(arguments, 0);\n            app.vent.trigger(args[0], args.slice(1));\n        });\n\n        /**\n         * On error, trigger the socket:error event on the global event aggregator for \n         * interested listeners.\n         */\n        socket.on('error', function(err){\n            app.vent.trigger('socket:error', err);\n        });\n\n        return socket;\n    }\n})(app /* replace with your global app object */, Backbone, Backbone.Marionette, jQuery, _, io);\n",[3881],{"type":21,"tag":78,"props":3882,"children":3883},{"__ignoreMap":8},[3884,3891,3898,3905,3913,3921,3928,3992,4015,4042,4049,4072,4087,4094,4101,4108,4115,4162,4189,4196,4203,4210,4217,4224,4271,4298,4321,4344,4351,4358,4365,4452,4459,4486,4525,4532,4591,4658,4673,4680,4688,4721,4729,4755,4762,4801,4829,4837,4863,4874,4881,4908,4923,4934,4941,4968,4983,4990,4997,5004,5027,5034,5041,5064,5071,5082,5089,5096,5103,5110,5117,5124,5131,5150,5157,5196,5231,5294,5301,5308,5315,5322,5329,5336,5343,5382,5437,5444,5483,5515,5523,5555,5563,5571,5580,5589,5609,5622,5630,5672,5704,5723,5731,5739,5748,5757,5766,5775,5808,5865,5909,5917,5925,5933,5942,5951,5959,6001,6027,6035,6043,6056,6064],{"type":21,"tag":111,"props":3885,"children":3886},{"class":113,"line":114},[3887],{"type":21,"tag":111,"props":3888,"children":3889},{"style":118},[3890],{"type":26,"value":121},{"type":21,"tag":111,"props":3892,"children":3893},{"class":113,"line":124},[3894],{"type":21,"tag":111,"props":3895,"children":3896},{"style":118},[3897],{"type":26,"value":130},{"type":21,"tag":111,"props":3899,"children":3900},{"class":113,"line":133},[3901],{"type":21,"tag":111,"props":3902,"children":3903},{"style":118},[3904],{"type":26,"value":139},{"type":21,"tag":111,"props":3906,"children":3907},{"class":113,"line":142},[3908],{"type":21,"tag":111,"props":3909,"children":3910},{"style":118},[3911],{"type":26,"value":3912}," * Overrides the default transport for Backbone syncing to use websockets via socket.io. Includes marionette     \n",{"type":21,"tag":111,"props":3914,"children":3915},{"class":113,"line":151},[3916],{"type":21,"tag":111,"props":3917,"children":3918},{"style":118},[3919],{"type":26,"value":3920}," * convenience code, specifically for sending socket-related events along the global event aggregator.\n",{"type":21,"tag":111,"props":3922,"children":3923},{"class":113,"line":160},[3924],{"type":21,"tag":111,"props":3925,"children":3926},{"style":118},[3927],{"type":26,"value":157},{"type":21,"tag":111,"props":3929,"children":3930},{"class":113,"line":219},[3931,3935,3939,3943,3948,3952,3956,3960,3964,3968,3972,3976,3980,3984,3988],{"type":21,"tag":111,"props":3932,"children":3933},{"style":164},[3934],{"type":26,"value":167},{"type":21,"tag":111,"props":3936,"children":3937},{"style":170},[3938],{"type":26,"value":173},{"type":21,"tag":111,"props":3940,"children":3941},{"style":164},[3942],{"type":26,"value":167},{"type":21,"tag":111,"props":3944,"children":3945},{"style":180},[3946],{"type":26,"value":3947},"app",{"type":21,"tag":111,"props":3949,"children":3950},{"style":164},[3951],{"type":26,"value":188},{"type":21,"tag":111,"props":3953,"children":3954},{"style":180},[3955],{"type":26,"value":183},{"type":21,"tag":111,"props":3957,"children":3958},{"style":164},[3959],{"type":26,"value":188},{"type":21,"tag":111,"props":3961,"children":3962},{"style":180},[3963],{"type":26,"value":36},{"type":21,"tag":111,"props":3965,"children":3966},{"style":164},[3967],{"type":26,"value":188},{"type":21,"tag":111,"props":3969,"children":3970},{"style":180},[3971],{"type":26,"value":193},{"type":21,"tag":111,"props":3973,"children":3974},{"style":164},[3975],{"type":26,"value":188},{"type":21,"tag":111,"props":3977,"children":3978},{"style":180},[3979],{"type":26,"value":202},{"type":21,"tag":111,"props":3981,"children":3982},{"style":164},[3983],{"type":26,"value":188},{"type":21,"tag":111,"props":3985,"children":3986},{"style":180},[3987],{"type":26,"value":211},{"type":21,"tag":111,"props":3989,"children":3990},{"style":164},[3991],{"type":26,"value":216},{"type":21,"tag":111,"props":3993,"children":3994},{"class":113,"line":249},[3995,3999,4003,4007,4011],{"type":21,"tag":111,"props":3996,"children":3997},{"style":170},[3998],{"type":26,"value":225},{"type":21,"tag":111,"props":4000,"children":4001},{"style":228},[4002],{"type":26,"value":231},{"type":21,"tag":111,"props":4004,"children":4005},{"style":170},[4006],{"type":26,"value":236},{"type":21,"tag":111,"props":4008,"children":4009},{"style":170},[4010],{"type":26,"value":241},{"type":21,"tag":111,"props":4012,"children":4013},{"style":164},[4014],{"type":26,"value":246},{"type":21,"tag":111,"props":4016,"children":4017},{"class":113,"line":283},[4018,4022,4026,4030,4034,4038],{"type":21,"tag":111,"props":4019,"children":4020},{"style":170},[4021],{"type":26,"value":255},{"type":21,"tag":111,"props":4023,"children":4024},{"style":170},[4025],{"type":26,"value":260},{"type":21,"tag":111,"props":4027,"children":4028},{"style":228},[4029],{"type":26,"value":265},{"type":21,"tag":111,"props":4031,"children":4032},{"style":164},[4033],{"type":26,"value":167},{"type":21,"tag":111,"props":4035,"children":4036},{"style":272},[4037],{"type":26,"value":275},{"type":21,"tag":111,"props":4039,"children":4040},{"style":164},[4041],{"type":26,"value":280},{"type":21,"tag":111,"props":4043,"children":4044},{"class":113,"line":292},[4045],{"type":21,"tag":111,"props":4046,"children":4047},{"style":164},[4048],{"type":26,"value":289},{"type":21,"tag":111,"props":4050,"children":4051},{"class":113,"line":322},[4052,4056,4060,4064,4068],{"type":21,"tag":111,"props":4053,"children":4054},{"style":164},[4055],{"type":26,"value":298},{"type":21,"tag":111,"props":4057,"children":4058},{"style":170},[4059],{"type":26,"value":303},{"type":21,"tag":111,"props":4061,"children":4062},{"style":164},[4063],{"type":26,"value":308},{"type":21,"tag":111,"props":4065,"children":4066},{"style":311},[4067],{"type":26,"value":314},{"type":21,"tag":111,"props":4069,"children":4070},{"style":164},[4071],{"type":26,"value":319},{"type":21,"tag":111,"props":4073,"children":4074},{"class":113,"line":340},[4075,4079,4083],{"type":21,"tag":111,"props":4076,"children":4077},{"style":164},[4078],{"type":26,"value":328},{"type":21,"tag":111,"props":4080,"children":4081},{"style":170},[4082],{"type":26,"value":303},{"type":21,"tag":111,"props":4084,"children":4085},{"style":164},[4086],{"type":26,"value":337},{"type":21,"tag":111,"props":4088,"children":4089},{"class":113,"line":350},[4090],{"type":21,"tag":111,"props":4091,"children":4092},{"emptyLinePlaceholder":344},[4093],{"type":26,"value":347},{"type":21,"tag":111,"props":4095,"children":4096},{"class":113,"line":359},[4097],{"type":21,"tag":111,"props":4098,"children":4099},{"style":118},[4100],{"type":26,"value":356},{"type":21,"tag":111,"props":4102,"children":4103},{"class":113,"line":368},[4104],{"type":21,"tag":111,"props":4105,"children":4106},{"style":118},[4107],{"type":26,"value":365},{"type":21,"tag":111,"props":4109,"children":4110},{"class":113,"line":377},[4111],{"type":21,"tag":111,"props":4112,"children":4113},{"style":118},[4114],{"type":26,"value":374},{"type":21,"tag":111,"props":4116,"children":4117},{"class":113,"line":430},[4118,4122,4126,4130,4134,4138,4142,4146,4150,4154,4158],{"type":21,"tag":111,"props":4119,"children":4120},{"style":164},[4121],{"type":26,"value":383},{"type":21,"tag":111,"props":4123,"children":4124},{"style":228},[4125],{"type":26,"value":388},{"type":21,"tag":111,"props":4127,"children":4128},{"style":170},[4129],{"type":26,"value":236},{"type":21,"tag":111,"props":4131,"children":4132},{"style":170},[4133],{"type":26,"value":241},{"type":21,"tag":111,"props":4135,"children":4136},{"style":164},[4137],{"type":26,"value":167},{"type":21,"tag":111,"props":4139,"children":4140},{"style":180},[4141],{"type":26,"value":405},{"type":21,"tag":111,"props":4143,"children":4144},{"style":164},[4145],{"type":26,"value":188},{"type":21,"tag":111,"props":4147,"children":4148},{"style":180},[4149],{"type":26,"value":414},{"type":21,"tag":111,"props":4151,"children":4152},{"style":164},[4153],{"type":26,"value":188},{"type":21,"tag":111,"props":4155,"children":4156},{"style":180},[4157],{"type":26,"value":423},{"type":21,"tag":111,"props":4159,"children":4160},{"style":164},[4161],{"type":26,"value":216},{"type":21,"tag":111,"props":4163,"children":4164},{"class":113,"line":463},[4165,4169,4173,4177,4181,4185],{"type":21,"tag":111,"props":4166,"children":4167},{"style":170},[4168],{"type":26,"value":436},{"type":21,"tag":111,"props":4170,"children":4171},{"style":164},[4172],{"type":26,"value":441},{"type":21,"tag":111,"props":4174,"children":4175},{"style":228},[4176],{"type":26,"value":446},{"type":21,"tag":111,"props":4178,"children":4179},{"style":164},[4180],{"type":26,"value":167},{"type":21,"tag":111,"props":4182,"children":4183},{"style":311},[4184],{"type":26,"value":455},{"type":21,"tag":111,"props":4186,"children":4187},{"style":164},[4188],{"type":26,"value":460},{"type":21,"tag":111,"props":4190,"children":4191},{"class":113,"line":472},[4192],{"type":21,"tag":111,"props":4193,"children":4194},{"style":164},[4195],{"type":26,"value":469},{"type":21,"tag":111,"props":4197,"children":4198},{"class":113,"line":480},[4199],{"type":21,"tag":111,"props":4200,"children":4201},{"emptyLinePlaceholder":344},[4202],{"type":26,"value":347},{"type":21,"tag":111,"props":4204,"children":4205},{"class":113,"line":488},[4206],{"type":21,"tag":111,"props":4207,"children":4208},{"style":118},[4209],{"type":26,"value":356},{"type":21,"tag":111,"props":4211,"children":4212},{"class":113,"line":497},[4213],{"type":21,"tag":111,"props":4214,"children":4215},{"style":118},[4216],{"type":26,"value":494},{"type":21,"tag":111,"props":4218,"children":4219},{"class":113,"line":505},[4220],{"type":21,"tag":111,"props":4221,"children":4222},{"style":118},[4223],{"type":26,"value":374},{"type":21,"tag":111,"props":4225,"children":4226},{"class":113,"line":554},[4227,4231,4235,4239,4243,4247,4251,4255,4259,4263,4267],{"type":21,"tag":111,"props":4228,"children":4229},{"style":164},[4230],{"type":26,"value":383},{"type":21,"tag":111,"props":4232,"children":4233},{"style":228},[4234],{"type":26,"value":515},{"type":21,"tag":111,"props":4236,"children":4237},{"style":170},[4238],{"type":26,"value":236},{"type":21,"tag":111,"props":4240,"children":4241},{"style":170},[4242],{"type":26,"value":241},{"type":21,"tag":111,"props":4244,"children":4245},{"style":164},[4246],{"type":26,"value":167},{"type":21,"tag":111,"props":4248,"children":4249},{"style":180},[4250],{"type":26,"value":405},{"type":21,"tag":111,"props":4252,"children":4253},{"style":164},[4254],{"type":26,"value":188},{"type":21,"tag":111,"props":4256,"children":4257},{"style":180},[4258],{"type":26,"value":414},{"type":21,"tag":111,"props":4260,"children":4261},{"style":164},[4262],{"type":26,"value":188},{"type":21,"tag":111,"props":4264,"children":4265},{"style":180},[4266],{"type":26,"value":423},{"type":21,"tag":111,"props":4268,"children":4269},{"style":164},[4270],{"type":26,"value":216},{"type":21,"tag":111,"props":4272,"children":4273},{"class":113,"line":587},[4274,4278,4282,4286,4290,4294],{"type":21,"tag":111,"props":4275,"children":4276},{"style":170},[4277],{"type":26,"value":560},{"type":21,"tag":111,"props":4279,"children":4280},{"style":164},[4281],{"type":26,"value":565},{"type":21,"tag":111,"props":4283,"children":4284},{"style":170},[4285],{"type":26,"value":303},{"type":21,"tag":111,"props":4287,"children":4288},{"style":164},[4289],{"type":26,"value":574},{"type":21,"tag":111,"props":4291,"children":4292},{"style":228},[4293],{"type":26,"value":579},{"type":21,"tag":111,"props":4295,"children":4296},{"style":164},[4297],{"type":26,"value":584},{"type":21,"tag":111,"props":4299,"children":4300},{"class":113,"line":615},[4301,4305,4309,4313,4317],{"type":21,"tag":111,"props":4302,"children":4303},{"style":164},[4304],{"type":26,"value":593},{"type":21,"tag":111,"props":4306,"children":4307},{"style":170},[4308],{"type":26,"value":303},{"type":21,"tag":111,"props":4310,"children":4311},{"style":164},[4312],{"type":26,"value":602},{"type":21,"tag":111,"props":4314,"children":4315},{"style":228},[4316],{"type":26,"value":607},{"type":21,"tag":111,"props":4318,"children":4319},{"style":164},[4320],{"type":26,"value":612},{"type":21,"tag":111,"props":4322,"children":4323},{"class":113,"line":642},[4324,4328,4332,4336,4340],{"type":21,"tag":111,"props":4325,"children":4326},{"style":164},[4327],{"type":26,"value":621},{"type":21,"tag":111,"props":4329,"children":4330},{"style":170},[4331],{"type":26,"value":303},{"type":21,"tag":111,"props":4333,"children":4334},{"style":164},[4335],{"type":26,"value":630},{"type":21,"tag":111,"props":4337,"children":4338},{"style":228},[4339],{"type":26,"value":635},{"type":21,"tag":111,"props":4341,"children":4342},{"style":164},[4343],{"type":26,"value":612},{"type":21,"tag":111,"props":4345,"children":4346},{"class":113,"line":651},[4347],{"type":21,"tag":111,"props":4348,"children":4349},{"style":164},[4350],{"type":26,"value":648},{"type":21,"tag":111,"props":4352,"children":4353},{"class":113,"line":660},[4354],{"type":21,"tag":111,"props":4355,"children":4356},{"style":164},[4357],{"type":26,"value":657},{"type":21,"tag":111,"props":4359,"children":4360},{"class":113,"line":668},[4361],{"type":21,"tag":111,"props":4362,"children":4363},{"emptyLinePlaceholder":344},[4364],{"type":26,"value":347},{"type":21,"tag":111,"props":4366,"children":4367},{"class":113,"line":769},[4368,4372,4376,4380,4384,4388,4392,4396,4400,4404,4408,4412,4416,4420,4424,4428,4432,4436,4440,4444,4448],{"type":21,"tag":111,"props":4369,"children":4370},{"style":164},[4371],{"type":26,"value":674},{"type":21,"tag":111,"props":4373,"children":4374},{"style":170},[4375],{"type":26,"value":303},{"type":21,"tag":111,"props":4377,"children":4378},{"style":164},[4379],{"type":26,"value":683},{"type":21,"tag":111,"props":4381,"children":4382},{"style":170},[4383],{"type":26,"value":688},{"type":21,"tag":111,"props":4385,"children":4386},{"style":164},[4387],{"type":26,"value":574},{"type":21,"tag":111,"props":4389,"children":4390},{"style":228},[4391],{"type":26,"value":697},{"type":21,"tag":111,"props":4393,"children":4394},{"style":164},[4395],{"type":26,"value":702},{"type":21,"tag":111,"props":4397,"children":4398},{"style":272},[4399],{"type":26,"value":707},{"type":21,"tag":111,"props":4401,"children":4402},{"style":164},[4403],{"type":26,"value":712},{"type":21,"tag":111,"props":4405,"children":4406},{"style":170},[4407],{"type":26,"value":717},{"type":21,"tag":111,"props":4409,"children":4410},{"style":164},[4411],{"type":26,"value":722},{"type":21,"tag":111,"props":4413,"children":4414},{"style":170},[4415],{"type":26,"value":688},{"type":21,"tag":111,"props":4417,"children":4418},{"style":164},[4419],{"type":26,"value":574},{"type":21,"tag":111,"props":4421,"children":4422},{"style":228},[4423],{"type":26,"value":697},{"type":21,"tag":111,"props":4425,"children":4426},{"style":164},[4427],{"type":26,"value":739},{"type":21,"tag":111,"props":4429,"children":4430},{"style":272},[4431],{"type":26,"value":707},{"type":21,"tag":111,"props":4433,"children":4434},{"style":164},[4435],{"type":26,"value":712},{"type":21,"tag":111,"props":4437,"children":4438},{"style":170},[4439],{"type":26,"value":717},{"type":21,"tag":111,"props":4441,"children":4442},{"style":170},[4443],{"type":26,"value":756},{"type":21,"tag":111,"props":4445,"children":4446},{"style":311},[4447],{"type":26,"value":761},{"type":21,"tag":111,"props":4449,"children":4450},{"style":164},[4451],{"type":26,"value":766},{"type":21,"tag":111,"props":4453,"children":4454},{"class":113,"line":778},[4455],{"type":21,"tag":111,"props":4456,"children":4457},{"style":118},[4458],{"type":26,"value":775},{"type":21,"tag":111,"props":4460,"children":4461},{"class":113,"line":812},[4462,4466,4470,4474,4478,4482],{"type":21,"tag":111,"props":4463,"children":4464},{"style":170},[4465],{"type":26,"value":784},{"type":21,"tag":111,"props":4467,"children":4468},{"style":164},[4469],{"type":26,"value":789},{"type":21,"tag":111,"props":4471,"children":4472},{"style":170},[4473],{"type":26,"value":794},{"type":21,"tag":111,"props":4475,"children":4476},{"style":164},[4477],{"type":26,"value":799},{"type":21,"tag":111,"props":4479,"children":4480},{"style":228},[4481],{"type":26,"value":804},{"type":21,"tag":111,"props":4483,"children":4484},{"style":164},[4485],{"type":26,"value":809},{"type":21,"tag":111,"props":4487,"children":4488},{"class":113,"line":821},[4489,4493,4497,4501,4505,4509,4513,4517,4521],{"type":21,"tag":111,"props":4490,"children":4491},{"style":164},[4492],{"type":26,"value":827},{"type":21,"tag":111,"props":4494,"children":4495},{"style":170},[4496],{"type":26,"value":303},{"type":21,"tag":111,"props":4498,"children":4499},{"style":164},[4500],{"type":26,"value":836},{"type":21,"tag":111,"props":4502,"children":4503},{"style":311},[4504],{"type":26,"value":314},{"type":21,"tag":111,"props":4506,"children":4507},{"style":164},[4508],{"type":26,"value":845},{"type":21,"tag":111,"props":4510,"children":4511},{"style":228},[4512],{"type":26,"value":446},{"type":21,"tag":111,"props":4514,"children":4515},{"style":164},[4516],{"type":26,"value":167},{"type":21,"tag":111,"props":4518,"children":4519},{"style":311},[4520],{"type":26,"value":455},{"type":21,"tag":111,"props":4522,"children":4523},{"style":164},[4524],{"type":26,"value":862},{"type":21,"tag":111,"props":4526,"children":4527},{"class":113,"line":865},[4528],{"type":21,"tag":111,"props":4529,"children":4530},{"style":118},[4531],{"type":26,"value":871},{"type":21,"tag":111,"props":4533,"children":4534},{"class":113,"line":874},[4535,4539,4543,4547,4551,4555,4559,4563,4567,4571,4575,4579,4583,4587],{"type":21,"tag":111,"props":4536,"children":4537},{"style":170},[4538],{"type":26,"value":784},{"type":21,"tag":111,"props":4540,"children":4541},{"style":164},[4542],{"type":26,"value":789},{"type":21,"tag":111,"props":4544,"children":4545},{"style":170},[4546],{"type":26,"value":794},{"type":21,"tag":111,"props":4548,"children":4549},{"style":164},[4550],{"type":26,"value":892},{"type":21,"tag":111,"props":4552,"children":4553},{"style":170},[4554],{"type":26,"value":897},{"type":21,"tag":111,"props":4556,"children":4557},{"style":164},[4558],{"type":26,"value":902},{"type":21,"tag":111,"props":4560,"children":4561},{"style":170},[4562],{"type":26,"value":303},{"type":21,"tag":111,"props":4564,"children":4565},{"style":164},[4566],{"type":26,"value":911},{"type":21,"tag":111,"props":4568,"children":4569},{"style":170},[4570],{"type":26,"value":916},{"type":21,"tag":111,"props":4572,"children":4573},{"style":164},[4574],{"type":26,"value":921},{"type":21,"tag":111,"props":4576,"children":4577},{"style":228},[4578],{"type":26,"value":926},{"type":21,"tag":111,"props":4580,"children":4581},{"style":164},[4582],{"type":26,"value":931},{"type":21,"tag":111,"props":4584,"children":4585},{"style":170},[4586],{"type":26,"value":916},{"type":21,"tag":111,"props":4588,"children":4589},{"style":164},[4590],{"type":26,"value":940},{"type":21,"tag":111,"props":4592,"children":4593},{"class":113,"line":943},[4594,4598,4602,4606,4610,4614,4618,4622,4626,4630,4634,4638,4642,4646,4650,4654],{"type":21,"tag":111,"props":4595,"children":4596},{"style":170},[4597],{"type":26,"value":784},{"type":21,"tag":111,"props":4599,"children":4600},{"style":164},[4601],{"type":26,"value":953},{"type":21,"tag":111,"props":4603,"children":4604},{"style":170},[4605],{"type":26,"value":958},{"type":21,"tag":111,"props":4607,"children":4608},{"style":311},[4609],{"type":26,"value":963},{"type":21,"tag":111,"props":4611,"children":4612},{"style":170},[4613],{"type":26,"value":968},{"type":21,"tag":111,"props":4615,"children":4616},{"style":164},[4617],{"type":26,"value":973},{"type":21,"tag":111,"props":4619,"children":4620},{"style":170},[4621],{"type":26,"value":958},{"type":21,"tag":111,"props":4623,"children":4624},{"style":170},[4625],{"type":26,"value":756},{"type":21,"tag":111,"props":4627,"children":4628},{"style":311},[4629],{"type":26,"value":761},{"type":21,"tag":111,"props":4631,"children":4632},{"style":164},[4633],{"type":26,"value":712},{"type":21,"tag":111,"props":4635,"children":4636},{"style":170},[4637],{"type":26,"value":897},{"type":21,"tag":111,"props":4639,"children":4640},{"style":164},[4641],{"type":26,"value":998},{"type":21,"tag":111,"props":4643,"children":4644},{"style":170},[4645],{"type":26,"value":958},{"type":21,"tag":111,"props":4647,"children":4648},{"style":311},[4649],{"type":26,"value":1007},{"type":21,"tag":111,"props":4651,"children":4652},{"style":170},[4653],{"type":26,"value":1012},{"type":21,"tag":111,"props":4655,"children":4656},{"style":164},[4657],{"type":26,"value":1017},{"type":21,"tag":111,"props":4659,"children":4660},{"class":113,"line":1020},[4661,4665,4669],{"type":21,"tag":111,"props":4662,"children":4663},{"style":164},[4664],{"type":26,"value":1026},{"type":21,"tag":111,"props":4666,"children":4667},{"style":170},[4668],{"type":26,"value":303},{"type":21,"tag":111,"props":4670,"children":4671},{"style":164},[4672],{"type":26,"value":1035},{"type":21,"tag":111,"props":4674,"children":4675},{"class":113,"line":1038},[4676],{"type":21,"tag":111,"props":4677,"children":4678},{"style":164},[4679],{"type":26,"value":1044},{"type":21,"tag":111,"props":4681,"children":4682},{"class":113,"line":1047},[4683],{"type":21,"tag":111,"props":4684,"children":4685},{"style":118},[4686],{"type":26,"value":4687},"        // Determine which websocket to use - set in options, on model, or on global app\n",{"type":21,"tag":111,"props":4689,"children":4690},{"class":113,"line":1056},[4691,4695,4699,4703,4707,4712,4716],{"type":21,"tag":111,"props":4692,"children":4693},{"style":164},[4694],{"type":26,"value":1062},{"type":21,"tag":111,"props":4696,"children":4697},{"style":170},[4698],{"type":26,"value":303},{"type":21,"tag":111,"props":4700,"children":4701},{"style":164},[4702],{"type":26,"value":1071},{"type":21,"tag":111,"props":4704,"children":4705},{"style":170},[4706],{"type":26,"value":916},{"type":21,"tag":111,"props":4708,"children":4709},{"style":164},[4710],{"type":26,"value":4711}," model.socket ",{"type":21,"tag":111,"props":4713,"children":4714},{"style":170},[4715],{"type":26,"value":916},{"type":21,"tag":111,"props":4717,"children":4718},{"style":164},[4719],{"type":26,"value":4720}," app.socket;\n",{"type":21,"tag":111,"props":4722,"children":4723},{"class":113,"line":1083},[4724],{"type":21,"tag":111,"props":4725,"children":4726},{"style":118},[4727],{"type":26,"value":4728},"        // Trigger the app event aggregator for interested listeners to know we're about to request data via websocket\n",{"type":21,"tag":111,"props":4730,"children":4731},{"class":113,"line":1092},[4732,4737,4741,4745,4750],{"type":21,"tag":111,"props":4733,"children":4734},{"style":164},[4735],{"type":26,"value":4736},"        app.vent.",{"type":21,"tag":111,"props":4738,"children":4739},{"style":228},[4740],{"type":26,"value":1400},{"type":21,"tag":111,"props":4742,"children":4743},{"style":164},[4744],{"type":26,"value":167},{"type":21,"tag":111,"props":4746,"children":4747},{"style":272},[4748],{"type":26,"value":4749},"'backbone:request'",{"type":21,"tag":111,"props":4751,"children":4752},{"style":164},[4753],{"type":26,"value":4754},", namespace);\n",{"type":21,"tag":111,"props":4756,"children":4757},{"class":113,"line":1138},[4758],{"type":21,"tag":111,"props":4759,"children":4760},{"style":118},[4761],{"type":26,"value":1089},{"type":21,"tag":111,"props":4763,"children":4764},{"class":113,"line":1175},[4765,4769,4773,4777,4781,4785,4789,4793,4797],{"type":21,"tag":111,"props":4766,"children":4767},{"style":164},[4768],{"type":26,"value":1098},{"type":21,"tag":111,"props":4770,"children":4771},{"style":228},[4772],{"type":26,"value":1103},{"type":21,"tag":111,"props":4774,"children":4775},{"style":164},[4776],{"type":26,"value":1108},{"type":21,"tag":111,"props":4778,"children":4779},{"style":170},[4780],{"type":26,"value":1113},{"type":21,"tag":111,"props":4782,"children":4783},{"style":164},[4784],{"type":26,"value":1118},{"type":21,"tag":111,"props":4786,"children":4787},{"style":170},[4788],{"type":26,"value":173},{"type":21,"tag":111,"props":4790,"children":4791},{"style":164},[4792],{"type":26,"value":167},{"type":21,"tag":111,"props":4794,"children":4795},{"style":180},[4796],{"type":26,"value":1131},{"type":21,"tag":111,"props":4798,"children":4799},{"style":164},[4800],{"type":26,"value":216},{"type":21,"tag":111,"props":4802,"children":4803},{"class":113,"line":1189},[4804,4808,4812,4816,4820,4824],{"type":21,"tag":111,"props":4805,"children":4806},{"style":170},[4807],{"type":26,"value":1144},{"type":21,"tag":111,"props":4809,"children":4810},{"style":164},[4811],{"type":26,"value":1149},{"type":21,"tag":111,"props":4813,"children":4814},{"style":170},[4815],{"type":26,"value":303},{"type":21,"tag":111,"props":4817,"children":4818},{"style":164},[4819],{"type":26,"value":1158},{"type":21,"tag":111,"props":4821,"children":4822},{"style":170},[4823],{"type":26,"value":897},{"type":21,"tag":111,"props":4825,"children":4826},{"style":164},[4827],{"type":26,"value":4828}," res.success);\n",{"type":21,"tag":111,"props":4830,"children":4831},{"class":113,"line":1198},[4832],{"type":21,"tag":111,"props":4833,"children":4834},{"style":118},[4835],{"type":26,"value":4836},"            // Trigger the app event aggregator to indicate we've received a return from the server, and success\n",{"type":21,"tag":111,"props":4838,"children":4839},{"class":113,"line":1232},[4840,4845,4849,4853,4858],{"type":21,"tag":111,"props":4841,"children":4842},{"style":164},[4843],{"type":26,"value":4844},"            app.vent.",{"type":21,"tag":111,"props":4846,"children":4847},{"style":228},[4848],{"type":26,"value":1400},{"type":21,"tag":111,"props":4850,"children":4851},{"style":164},[4852],{"type":26,"value":167},{"type":21,"tag":111,"props":4854,"children":4855},{"style":272},[4856],{"type":26,"value":4857},"'backbone:receive'",{"type":21,"tag":111,"props":4859,"children":4860},{"style":164},[4861],{"type":26,"value":4862},", namespace, success);\n",{"type":21,"tag":111,"props":4864,"children":4865},{"class":113,"line":1250},[4866,4870],{"type":21,"tag":111,"props":4867,"children":4868},{"style":170},[4869],{"type":26,"value":1181},{"type":21,"tag":111,"props":4871,"children":4872},{"style":164},[4873],{"type":26,"value":1186},{"type":21,"tag":111,"props":4875,"children":4876},{"class":113,"line":1263},[4877],{"type":21,"tag":111,"props":4878,"children":4879},{"style":164},[4880],{"type":26,"value":1195},{"type":21,"tag":111,"props":4882,"children":4883},{"class":113,"line":1272},[4884,4888,4892,4896,4900,4904],{"type":21,"tag":111,"props":4885,"children":4886},{"style":170},[4887],{"type":26,"value":1204},{"type":21,"tag":111,"props":4889,"children":4890},{"style":164},[4891],{"type":26,"value":1209},{"type":21,"tag":111,"props":4893,"children":4894},{"style":228},[4895],{"type":26,"value":1214},{"type":21,"tag":111,"props":4897,"children":4898},{"style":164},[4899],{"type":26,"value":1219},{"type":21,"tag":111,"props":4901,"children":4902},{"style":228},[4903],{"type":26,"value":1224},{"type":21,"tag":111,"props":4905,"children":4906},{"style":164},[4907],{"type":26,"value":1229},{"type":21,"tag":111,"props":4909,"children":4910},{"class":113,"line":1302},[4911,4915,4919],{"type":21,"tag":111,"props":4912,"children":4913},{"style":164},[4914],{"type":26,"value":1238},{"type":21,"tag":111,"props":4916,"children":4917},{"style":228},[4918],{"type":26,"value":1243},{"type":21,"tag":111,"props":4920,"children":4921},{"style":164},[4922],{"type":26,"value":1229},{"type":21,"tag":111,"props":4924,"children":4925},{"class":113,"line":1320},[4926,4930],{"type":21,"tag":111,"props":4927,"children":4928},{"style":170},[4929],{"type":26,"value":1256},{"type":21,"tag":111,"props":4931,"children":4932},{"style":164},[4933],{"type":26,"value":766},{"type":21,"tag":111,"props":4935,"children":4936},{"class":113,"line":1329},[4937],{"type":21,"tag":111,"props":4938,"children":4939},{"style":164},[4940],{"type":26,"value":1269},{"type":21,"tag":111,"props":4942,"children":4943},{"class":113,"line":1337},[4944,4948,4952,4956,4960,4964],{"type":21,"tag":111,"props":4945,"children":4946},{"style":170},[4947],{"type":26,"value":1181},{"type":21,"tag":111,"props":4949,"children":4950},{"style":164},[4951],{"type":26,"value":1209},{"type":21,"tag":111,"props":4953,"children":4954},{"style":228},[4955],{"type":26,"value":1214},{"type":21,"tag":111,"props":4957,"children":4958},{"style":164},[4959],{"type":26,"value":1290},{"type":21,"tag":111,"props":4961,"children":4962},{"style":228},[4963],{"type":26,"value":1295},{"type":21,"tag":111,"props":4965,"children":4966},{"style":164},[4967],{"type":26,"value":1229},{"type":21,"tag":111,"props":4969,"children":4970},{"class":113,"line":1346},[4971,4975,4979],{"type":21,"tag":111,"props":4972,"children":4973},{"style":164},[4974],{"type":26,"value":1308},{"type":21,"tag":111,"props":4976,"children":4977},{"style":228},[4978],{"type":26,"value":1313},{"type":21,"tag":111,"props":4980,"children":4981},{"style":164},[4982],{"type":26,"value":1229},{"type":21,"tag":111,"props":4984,"children":4985},{"class":113,"line":1372},[4986],{"type":21,"tag":111,"props":4987,"children":4988},{"style":164},[4989],{"type":26,"value":1326},{"type":21,"tag":111,"props":4991,"children":4992},{"class":113,"line":1380},[4993],{"type":21,"tag":111,"props":4994,"children":4995},{"emptyLinePlaceholder":344},[4996],{"type":26,"value":347},{"type":21,"tag":111,"props":4998,"children":4999},{"class":113,"line":1389},[5000],{"type":21,"tag":111,"props":5001,"children":5002},{"style":118},[5003],{"type":26,"value":1343},{"type":21,"tag":111,"props":5005,"children":5006},{"class":113,"line":1417},[5007,5011,5015,5019,5023],{"type":21,"tag":111,"props":5008,"children":5009},{"style":164},[5010],{"type":26,"value":1098},{"type":21,"tag":111,"props":5012,"children":5013},{"style":228},[5014],{"type":26,"value":1356},{"type":21,"tag":111,"props":5016,"children":5017},{"style":164},[5018],{"type":26,"value":1108},{"type":21,"tag":111,"props":5020,"children":5021},{"style":170},[5022],{"type":26,"value":1113},{"type":21,"tag":111,"props":5024,"children":5025},{"style":164},[5026],{"type":26,"value":1369},{"type":21,"tag":111,"props":5028,"children":5029},{"class":113,"line":1426},[5030],{"type":21,"tag":111,"props":5031,"children":5032},{"emptyLinePlaceholder":344},[5033],{"type":26,"value":347},{"type":21,"tag":111,"props":5035,"children":5036},{"class":113,"line":1439},[5037],{"type":21,"tag":111,"props":5038,"children":5039},{"style":118},[5040],{"type":26,"value":1386},{"type":21,"tag":111,"props":5042,"children":5043},{"class":113,"line":1447},[5044,5048,5052,5056,5060],{"type":21,"tag":111,"props":5045,"children":5046},{"style":164},[5047],{"type":26,"value":1395},{"type":21,"tag":111,"props":5049,"children":5050},{"style":228},[5051],{"type":26,"value":1400},{"type":21,"tag":111,"props":5053,"children":5054},{"style":164},[5055],{"type":26,"value":167},{"type":21,"tag":111,"props":5057,"children":5058},{"style":272},[5059],{"type":26,"value":1409},{"type":21,"tag":111,"props":5061,"children":5062},{"style":164},[5063],{"type":26,"value":1414},{"type":21,"tag":111,"props":5065,"children":5066},{"class":113,"line":1455},[5067],{"type":21,"tag":111,"props":5068,"children":5069},{"style":118},[5070],{"type":26,"value":1423},{"type":21,"tag":111,"props":5072,"children":5073},{"class":113,"line":1463},[5074,5078],{"type":21,"tag":111,"props":5075,"children":5076},{"style":170},[5077],{"type":26,"value":436},{"type":21,"tag":111,"props":5079,"children":5080},{"style":164},[5081],{"type":26,"value":1436},{"type":21,"tag":111,"props":5083,"children":5084},{"class":113,"line":1472},[5085],{"type":21,"tag":111,"props":5086,"children":5087},{"style":164},[5088],{"type":26,"value":469},{"type":21,"tag":111,"props":5090,"children":5091},{"class":113,"line":1481},[5092],{"type":21,"tag":111,"props":5093,"children":5094},{"emptyLinePlaceholder":344},[5095],{"type":26,"value":347},{"type":21,"tag":111,"props":5097,"children":5098},{"class":113,"line":1490},[5099],{"type":21,"tag":111,"props":5100,"children":5101},{"style":118},[5102],{"type":26,"value":356},{"type":21,"tag":111,"props":5104,"children":5105},{"class":113,"line":1499},[5106],{"type":21,"tag":111,"props":5107,"children":5108},{"style":118},[5109],{"type":26,"value":1469},{"type":21,"tag":111,"props":5111,"children":5112},{"class":113,"line":1523},[5113],{"type":21,"tag":111,"props":5114,"children":5115},{"style":118},[5116],{"type":26,"value":1478},{"type":21,"tag":111,"props":5118,"children":5119},{"class":113,"line":1531},[5120],{"type":21,"tag":111,"props":5121,"children":5122},{"style":118},[5123],{"type":26,"value":1487},{"type":21,"tag":111,"props":5125,"children":5126},{"class":113,"line":1574},[5127],{"type":21,"tag":111,"props":5128,"children":5129},{"style":118},[5130],{"type":26,"value":1496},{"type":21,"tag":111,"props":5132,"children":5133},{"class":113,"line":1613},[5134,5138,5142,5146],{"type":21,"tag":111,"props":5135,"children":5136},{"style":118},[5137],{"type":26,"value":1505},{"type":21,"tag":111,"props":5139,"children":5140},{"style":170},[5141],{"type":26,"value":1510},{"type":21,"tag":111,"props":5143,"children":5144},{"style":228},[5145],{"type":26,"value":1515},{"type":21,"tag":111,"props":5147,"children":5148},{"style":164},[5149],{"type":26,"value":1520},{"type":21,"tag":111,"props":5151,"children":5152},{"class":113,"line":1684},[5153],{"type":21,"tag":111,"props":5154,"children":5155},{"style":118},[5156],{"type":26,"value":374},{"type":21,"tag":111,"props":5158,"children":5159},{"class":113,"line":1692},[5160,5164,5168,5172,5176,5180,5184,5188,5192],{"type":21,"tag":111,"props":5161,"children":5162},{"style":164},[5163],{"type":26,"value":1537},{"type":21,"tag":111,"props":5165,"children":5166},{"style":311},[5167],{"type":26,"value":314},{"type":21,"tag":111,"props":5169,"children":5170},{"style":164},[5171],{"type":26,"value":62},{"type":21,"tag":111,"props":5173,"children":5174},{"style":228},[5175],{"type":26,"value":1550},{"type":21,"tag":111,"props":5177,"children":5178},{"style":170},[5179],{"type":26,"value":236},{"type":21,"tag":111,"props":5181,"children":5182},{"style":170},[5183],{"type":26,"value":241},{"type":21,"tag":111,"props":5185,"children":5186},{"style":164},[5187],{"type":26,"value":167},{"type":21,"tag":111,"props":5189,"children":5190},{"style":180},[5191],{"type":26,"value":1567},{"type":21,"tag":111,"props":5193,"children":5194},{"style":164},[5195],{"type":26,"value":216},{"type":21,"tag":111,"props":5197,"children":5198},{"class":113,"line":1700},[5199,5203,5207,5211,5215,5219,5223,5227],{"type":21,"tag":111,"props":5200,"children":5201},{"style":164},[5202],{"type":26,"value":1580},{"type":21,"tag":111,"props":5204,"children":5205},{"style":170},[5206],{"type":26,"value":303},{"type":21,"tag":111,"props":5208,"children":5209},{"style":164},[5210],{"type":26,"value":1589},{"type":21,"tag":111,"props":5212,"children":5213},{"style":170},[5214],{"type":26,"value":916},{"type":21,"tag":111,"props":5216,"children":5217},{"style":311},[5218],{"type":26,"value":1598},{"type":21,"tag":111,"props":5220,"children":5221},{"style":164},[5222],{"type":26,"value":62},{"type":21,"tag":111,"props":5224,"children":5225},{"style":228},[5226],{"type":26,"value":1567},{"type":21,"tag":111,"props":5228,"children":5229},{"style":164},[5230],{"type":26,"value":809},{"type":21,"tag":111,"props":5232,"children":5233},{"class":113,"line":1708},[5234,5238,5242,5246,5250,5254,5258,5262,5266,5270,5274,5278,5282,5286,5290],{"type":21,"tag":111,"props":5235,"children":5236},{"style":170},[5237],{"type":26,"value":436},{"type":21,"tag":111,"props":5239,"children":5240},{"style":164},[5241],{"type":26,"value":574},{"type":21,"tag":111,"props":5243,"children":5244},{"style":228},[5245],{"type":26,"value":1627},{"type":21,"tag":111,"props":5247,"children":5248},{"style":164},[5249],{"type":26,"value":1632},{"type":21,"tag":111,"props":5251,"children":5252},{"style":272},[5253],{"type":26,"value":1637},{"type":21,"tag":111,"props":5255,"children":5256},{"style":164},[5257],{"type":26,"value":1642},{"type":21,"tag":111,"props":5259,"children":5260},{"style":228},[5261],{"type":26,"value":1647},{"type":21,"tag":111,"props":5263,"children":5264},{"style":164},[5265],{"type":26,"value":167},{"type":21,"tag":111,"props":5267,"children":5268},{"style":272},[5269],{"type":26,"value":1637},{"type":21,"tag":111,"props":5271,"children":5272},{"style":164},[5273],{"type":26,"value":188},{"type":21,"tag":111,"props":5275,"children":5276},{"style":272},[5277],{"type":26,"value":1664},{"type":21,"tag":111,"props":5279,"children":5280},{"style":164},[5281],{"type":26,"value":712},{"type":21,"tag":111,"props":5283,"children":5284},{"style":170},[5285],{"type":26,"value":1113},{"type":21,"tag":111,"props":5287,"children":5288},{"style":272},[5289],{"type":26,"value":1677},{"type":21,"tag":111,"props":5291,"children":5292},{"style":164},[5293],{"type":26,"value":766},{"type":21,"tag":111,"props":5295,"children":5296},{"class":113,"line":1717},[5297],{"type":21,"tag":111,"props":5298,"children":5299},{"style":164},[5300],{"type":26,"value":469},{"type":21,"tag":111,"props":5302,"children":5303},{"class":113,"line":1726},[5304],{"type":21,"tag":111,"props":5305,"children":5306},{"emptyLinePlaceholder":344},[5307],{"type":26,"value":347},{"type":21,"tag":111,"props":5309,"children":5310},{"class":113,"line":1735},[5311],{"type":21,"tag":111,"props":5312,"children":5313},{"style":118},[5314],{"type":26,"value":356},{"type":21,"tag":111,"props":5316,"children":5317},{"class":113,"line":1744},[5318],{"type":21,"tag":111,"props":5319,"children":5320},{"style":118},[5321],{"type":26,"value":1714},{"type":21,"tag":111,"props":5323,"children":5324},{"class":113,"line":1786},[5325],{"type":21,"tag":111,"props":5326,"children":5327},{"style":118},[5328],{"type":26,"value":1723},{"type":21,"tag":111,"props":5330,"children":5331},{"class":113,"line":1847},[5332],{"type":21,"tag":111,"props":5333,"children":5334},{"style":118},[5335],{"type":26,"value":1732},{"type":21,"tag":111,"props":5337,"children":5338},{"class":113,"line":1855},[5339],{"type":21,"tag":111,"props":5340,"children":5341},{"style":118},[5342],{"type":26,"value":1741},{"type":21,"tag":111,"props":5344,"children":5345},{"class":113,"line":1902},[5346,5350,5354,5358,5362,5366,5370,5374,5378],{"type":21,"tag":111,"props":5347,"children":5348},{"style":164},[5349],{"type":26,"value":1750},{"type":21,"tag":111,"props":5351,"children":5352},{"style":311},[5353],{"type":26,"value":314},{"type":21,"tag":111,"props":5355,"children":5356},{"style":164},[5357],{"type":26,"value":62},{"type":21,"tag":111,"props":5359,"children":5360},{"style":228},[5361],{"type":26,"value":1356},{"type":21,"tag":111,"props":5363,"children":5364},{"style":170},[5365],{"type":26,"value":236},{"type":21,"tag":111,"props":5367,"children":5368},{"style":170},[5369],{"type":26,"value":241},{"type":21,"tag":111,"props":5371,"children":5372},{"style":164},[5373],{"type":26,"value":167},{"type":21,"tag":111,"props":5375,"children":5376},{"style":180},[5377],{"type":26,"value":1779},{"type":21,"tag":111,"props":5379,"children":5380},{"style":164},[5381],{"type":26,"value":216},{"type":21,"tag":111,"props":5383,"children":5384},{"class":113,"line":1935},[5385,5389,5393,5397,5401,5405,5409,5413,5417,5421,5425,5429,5433],{"type":21,"tag":111,"props":5386,"children":5387},{"style":170},[5388],{"type":26,"value":560},{"type":21,"tag":111,"props":5390,"children":5391},{"style":164},[5392],{"type":26,"value":1796},{"type":21,"tag":111,"props":5394,"children":5395},{"style":170},[5396],{"type":26,"value":303},{"type":21,"tag":111,"props":5398,"children":5399},{"style":311},[5400],{"type":26,"value":1805},{"type":21,"tag":111,"props":5402,"children":5403},{"style":164},[5404],{"type":26,"value":62},{"type":21,"tag":111,"props":5406,"children":5407},{"style":311},[5408],{"type":26,"value":314},{"type":21,"tag":111,"props":5410,"children":5411},{"style":164},[5412],{"type":26,"value":1818},{"type":21,"tag":111,"props":5414,"children":5415},{"style":228},[5416],{"type":26,"value":446},{"type":21,"tag":111,"props":5418,"children":5419},{"style":164},[5420],{"type":26,"value":167},{"type":21,"tag":111,"props":5422,"children":5423},{"style":311},[5424],{"type":26,"value":1831},{"type":21,"tag":111,"props":5426,"children":5427},{"style":164},[5428],{"type":26,"value":188},{"type":21,"tag":111,"props":5430,"children":5431},{"style":311},[5432],{"type":26,"value":1840},{"type":21,"tag":111,"props":5434,"children":5435},{"style":164},[5436],{"type":26,"value":280},{"type":21,"tag":111,"props":5438,"children":5439},{"class":113,"line":1943},[5440],{"type":21,"tag":111,"props":5441,"children":5442},{"emptyLinePlaceholder":344},[5443],{"type":26,"value":347},{"type":21,"tag":111,"props":5445,"children":5446},{"class":113,"line":1978},[5447,5451,5455,5459,5463,5467,5471,5475,5479],{"type":21,"tag":111,"props":5448,"children":5449},{"style":164},[5450],{"type":26,"value":1861},{"type":21,"tag":111,"props":5452,"children":5453},{"style":228},[5454],{"type":26,"value":1866},{"type":21,"tag":111,"props":5456,"children":5457},{"style":164},[5458],{"type":26,"value":167},{"type":21,"tag":111,"props":5460,"children":5461},{"style":311},[5462],{"type":26,"value":455},{"type":21,"tag":111,"props":5464,"children":5465},{"style":164},[5466],{"type":26,"value":1879},{"type":21,"tag":111,"props":5468,"children":5469},{"style":272},[5470],{"type":26,"value":1884},{"type":21,"tag":111,"props":5472,"children":5473},{"style":164},[5474],{"type":26,"value":1889},{"type":21,"tag":111,"props":5476,"children":5477},{"style":228},[5478],{"type":26,"value":1894},{"type":21,"tag":111,"props":5480,"children":5481},{"style":164},[5482],{"type":26,"value":1899},{"type":21,"tag":111,"props":5484,"children":5486},{"class":113,"line":5485},89,[5487,5491,5495,5499,5503,5507,5511],{"type":21,"tag":111,"props":5488,"children":5489},{"style":164},[5490],{"type":26,"value":1861},{"type":21,"tag":111,"props":5492,"children":5493},{"style":228},[5494],{"type":26,"value":1866},{"type":21,"tag":111,"props":5496,"children":5497},{"style":164},[5498],{"type":26,"value":167},{"type":21,"tag":111,"props":5500,"children":5501},{"style":311},[5502],{"type":26,"value":455},{"type":21,"tag":111,"props":5504,"children":5505},{"style":164},[5506],{"type":26,"value":1924},{"type":21,"tag":111,"props":5508,"children":5509},{"style":228},[5510],{"type":26,"value":1894},{"type":21,"tag":111,"props":5512,"children":5513},{"style":164},[5514],{"type":26,"value":1899},{"type":21,"tag":111,"props":5516,"children":5518},{"class":113,"line":5517},90,[5519],{"type":21,"tag":111,"props":5520,"children":5521},{"style":164},[5522],{"type":26,"value":469},{"type":21,"tag":111,"props":5524,"children":5526},{"class":113,"line":5525},91,[5527,5531,5535,5539,5543,5547,5551],{"type":21,"tag":111,"props":5528,"children":5529},{"style":164},[5530],{"type":26,"value":1949},{"type":21,"tag":111,"props":5532,"children":5533},{"style":311},[5534],{"type":26,"value":314},{"type":21,"tag":111,"props":5536,"children":5537},{"style":164},[5538],{"type":26,"value":1958},{"type":21,"tag":111,"props":5540,"children":5541},{"style":170},[5542],{"type":26,"value":303},{"type":21,"tag":111,"props":5544,"children":5545},{"style":164},[5546],{"type":26,"value":308},{"type":21,"tag":111,"props":5548,"children":5549},{"style":311},[5550],{"type":26,"value":314},{"type":21,"tag":111,"props":5552,"children":5553},{"style":164},[5554],{"type":26,"value":1975},{"type":21,"tag":111,"props":5556,"children":5558},{"class":113,"line":5557},92,[5559],{"type":21,"tag":111,"props":5560,"children":5561},{"emptyLinePlaceholder":344},[5562],{"type":26,"value":347},{"type":21,"tag":111,"props":5564,"children":5566},{"class":113,"line":5565},93,[5567],{"type":21,"tag":111,"props":5568,"children":5569},{"style":118},[5570],{"type":26,"value":356},{"type":21,"tag":111,"props":5572,"children":5574},{"class":113,"line":5573},94,[5575],{"type":21,"tag":111,"props":5576,"children":5577},{"style":118},[5578],{"type":26,"value":5579},"     * Create a socket io instance that will echo all events into the application event aggregator, so that\n",{"type":21,"tag":111,"props":5581,"children":5583},{"class":113,"line":5582},95,[5584],{"type":21,"tag":111,"props":5585,"children":5586},{"style":118},[5587],{"type":26,"value":5588},"     * collections, models, etc. can listen on app.vent for their events.\n",{"type":21,"tag":111,"props":5590,"children":5592},{"class":113,"line":5591},96,[5593,5597,5601,5605],{"type":21,"tag":111,"props":5594,"children":5595},{"style":118},[5596],{"type":26,"value":1505},{"type":21,"tag":111,"props":5598,"children":5599},{"style":170},[5600],{"type":26,"value":1510},{"type":21,"tag":111,"props":5602,"children":5603},{"style":228},[5604],{"type":26,"value":1515},{"type":21,"tag":111,"props":5606,"children":5607},{"style":164},[5608],{"type":26,"value":1520},{"type":21,"tag":111,"props":5610,"children":5612},{"class":113,"line":5611},97,[5613,5617],{"type":21,"tag":111,"props":5614,"children":5615},{"style":118},[5616],{"type":26,"value":1505},{"type":21,"tag":111,"props":5618,"children":5619},{"style":170},[5620],{"type":26,"value":5621},"@constructor\n",{"type":21,"tag":111,"props":5623,"children":5625},{"class":113,"line":5624},98,[5626],{"type":21,"tag":111,"props":5627,"children":5628},{"style":118},[5629],{"type":26,"value":374},{"type":21,"tag":111,"props":5631,"children":5633},{"class":113,"line":5632},99,[5634,5639,5643,5647,5652,5656,5660,5664,5668],{"type":21,"tag":111,"props":5635,"children":5636},{"style":164},[5637],{"type":26,"value":5638},"    Marionette.Application.",{"type":21,"tag":111,"props":5640,"children":5641},{"style":311},[5642],{"type":26,"value":314},{"type":21,"tag":111,"props":5644,"children":5645},{"style":164},[5646],{"type":26,"value":62},{"type":21,"tag":111,"props":5648,"children":5649},{"style":228},[5650],{"type":26,"value":5651},"SocketIO",{"type":21,"tag":111,"props":5653,"children":5654},{"style":170},[5655],{"type":26,"value":236},{"type":21,"tag":111,"props":5657,"children":5658},{"style":170},[5659],{"type":26,"value":241},{"type":21,"tag":111,"props":5661,"children":5662},{"style":164},[5663],{"type":26,"value":167},{"type":21,"tag":111,"props":5665,"children":5666},{"style":180},[5667],{"type":26,"value":1567},{"type":21,"tag":111,"props":5669,"children":5670},{"style":164},[5671],{"type":26,"value":216},{"type":21,"tag":111,"props":5673,"children":5675},{"class":113,"line":5674},100,[5676,5680,5685,5689,5694,5699],{"type":21,"tag":111,"props":5677,"children":5678},{"style":170},[5679],{"type":26,"value":560},{"type":21,"tag":111,"props":5681,"children":5682},{"style":164},[5683],{"type":26,"value":5684}," socket ",{"type":21,"tag":111,"props":5686,"children":5687},{"style":170},[5688],{"type":26,"value":303},{"type":21,"tag":111,"props":5690,"children":5691},{"style":164},[5692],{"type":26,"value":5693}," io.",{"type":21,"tag":111,"props":5695,"children":5696},{"style":228},[5697],{"type":26,"value":5698},"connect",{"type":21,"tag":111,"props":5700,"children":5701},{"style":164},[5702],{"type":26,"value":5703},"(url, {\n",{"type":21,"tag":111,"props":5705,"children":5707},{"class":113,"line":5706},101,[5708,5713,5718],{"type":21,"tag":111,"props":5709,"children":5710},{"style":164},[5711],{"type":26,"value":5712},"            transports:[",{"type":21,"tag":111,"props":5714,"children":5715},{"style":272},[5716],{"type":26,"value":5717},"'websocket'",{"type":21,"tag":111,"props":5719,"children":5720},{"style":164},[5721],{"type":26,"value":5722},"]\n",{"type":21,"tag":111,"props":5724,"children":5726},{"class":113,"line":5725},102,[5727],{"type":21,"tag":111,"props":5728,"children":5729},{"style":164},[5730],{"type":26,"value":1326},{"type":21,"tag":111,"props":5732,"children":5734},{"class":113,"line":5733},103,[5735],{"type":21,"tag":111,"props":5736,"children":5737},{"emptyLinePlaceholder":344},[5738],{"type":26,"value":347},{"type":21,"tag":111,"props":5740,"children":5742},{"class":113,"line":5741},104,[5743],{"type":21,"tag":111,"props":5744,"children":5745},{"style":118},[5746],{"type":26,"value":5747},"        /**\n",{"type":21,"tag":111,"props":5749,"children":5751},{"class":113,"line":5750},105,[5752],{"type":21,"tag":111,"props":5753,"children":5754},{"style":118},[5755],{"type":26,"value":5756},"         * On any event from the server, trigger it on the app event aggregator. The first\n",{"type":21,"tag":111,"props":5758,"children":5760},{"class":113,"line":5759},106,[5761],{"type":21,"tag":111,"props":5762,"children":5763},{"style":118},[5764],{"type":26,"value":5765},"         * argument will always be the name of the event.\n",{"type":21,"tag":111,"props":5767,"children":5769},{"class":113,"line":5768},107,[5770],{"type":21,"tag":111,"props":5771,"children":5772},{"style":118},[5773],{"type":26,"value":5774},"         */\n",{"type":21,"tag":111,"props":5776,"children":5778},{"class":113,"line":5777},108,[5779,5783,5788,5792,5796,5800,5804],{"type":21,"tag":111,"props":5780,"children":5781},{"style":164},[5782],{"type":26,"value":1098},{"type":21,"tag":111,"props":5784,"children":5785},{"style":228},[5786],{"type":26,"value":5787},"on",{"type":21,"tag":111,"props":5789,"children":5790},{"style":164},[5791],{"type":26,"value":167},{"type":21,"tag":111,"props":5793,"children":5794},{"style":272},[5795],{"type":26,"value":1884},{"type":21,"tag":111,"props":5797,"children":5798},{"style":164},[5799],{"type":26,"value":188},{"type":21,"tag":111,"props":5801,"children":5802},{"style":170},[5803],{"type":26,"value":173},{"type":21,"tag":111,"props":5805,"children":5806},{"style":164},[5807],{"type":26,"value":246},{"type":21,"tag":111,"props":5809,"children":5811},{"class":113,"line":5810},109,[5812,5816,5820,5824,5828,5832,5836,5840,5844,5848,5852,5856,5861],{"type":21,"tag":111,"props":5813,"children":5814},{"style":170},[5815],{"type":26,"value":1144},{"type":21,"tag":111,"props":5817,"children":5818},{"style":164},[5819],{"type":26,"value":1796},{"type":21,"tag":111,"props":5821,"children":5822},{"style":170},[5823],{"type":26,"value":303},{"type":21,"tag":111,"props":5825,"children":5826},{"style":311},[5827],{"type":26,"value":1805},{"type":21,"tag":111,"props":5829,"children":5830},{"style":164},[5831],{"type":26,"value":62},{"type":21,"tag":111,"props":5833,"children":5834},{"style":311},[5835],{"type":26,"value":314},{"type":21,"tag":111,"props":5837,"children":5838},{"style":164},[5839],{"type":26,"value":1818},{"type":21,"tag":111,"props":5841,"children":5842},{"style":228},[5843],{"type":26,"value":446},{"type":21,"tag":111,"props":5845,"children":5846},{"style":164},[5847],{"type":26,"value":167},{"type":21,"tag":111,"props":5849,"children":5850},{"style":311},[5851],{"type":26,"value":1831},{"type":21,"tag":111,"props":5853,"children":5854},{"style":164},[5855],{"type":26,"value":188},{"type":21,"tag":111,"props":5857,"children":5858},{"style":311},[5859],{"type":26,"value":5860},"0",{"type":21,"tag":111,"props":5862,"children":5863},{"style":164},[5864],{"type":26,"value":280},{"type":21,"tag":111,"props":5866,"children":5868},{"class":113,"line":5867},110,[5869,5873,5877,5882,5886,5891,5896,5900,5904],{"type":21,"tag":111,"props":5870,"children":5871},{"style":164},[5872],{"type":26,"value":4844},{"type":21,"tag":111,"props":5874,"children":5875},{"style":228},[5876],{"type":26,"value":1400},{"type":21,"tag":111,"props":5878,"children":5879},{"style":164},[5880],{"type":26,"value":5881},"(args[",{"type":21,"tag":111,"props":5883,"children":5884},{"style":311},[5885],{"type":26,"value":5860},{"type":21,"tag":111,"props":5887,"children":5888},{"style":164},[5889],{"type":26,"value":5890},"], args.",{"type":21,"tag":111,"props":5892,"children":5893},{"style":228},[5894],{"type":26,"value":5895},"slice",{"type":21,"tag":111,"props":5897,"children":5898},{"style":164},[5899],{"type":26,"value":167},{"type":21,"tag":111,"props":5901,"children":5902},{"style":311},[5903],{"type":26,"value":1840},{"type":21,"tag":111,"props":5905,"children":5906},{"style":164},[5907],{"type":26,"value":5908},"));\n",{"type":21,"tag":111,"props":5910,"children":5912},{"class":113,"line":5911},111,[5913],{"type":21,"tag":111,"props":5914,"children":5915},{"style":164},[5916],{"type":26,"value":1326},{"type":21,"tag":111,"props":5918,"children":5920},{"class":113,"line":5919},112,[5921],{"type":21,"tag":111,"props":5922,"children":5923},{"emptyLinePlaceholder":344},[5924],{"type":26,"value":347},{"type":21,"tag":111,"props":5926,"children":5928},{"class":113,"line":5927},113,[5929],{"type":21,"tag":111,"props":5930,"children":5931},{"style":118},[5932],{"type":26,"value":5747},{"type":21,"tag":111,"props":5934,"children":5936},{"class":113,"line":5935},114,[5937],{"type":21,"tag":111,"props":5938,"children":5939},{"style":118},[5940],{"type":26,"value":5941},"         * On error, trigger the socket:error event on the global event aggregator for \n",{"type":21,"tag":111,"props":5943,"children":5945},{"class":113,"line":5944},115,[5946],{"type":21,"tag":111,"props":5947,"children":5948},{"style":118},[5949],{"type":26,"value":5950},"         * interested listeners.\n",{"type":21,"tag":111,"props":5952,"children":5954},{"class":113,"line":5953},116,[5955],{"type":21,"tag":111,"props":5956,"children":5957},{"style":118},[5958],{"type":26,"value":5774},{"type":21,"tag":111,"props":5960,"children":5962},{"class":113,"line":5961},117,[5963,5967,5971,5975,5980,5984,5988,5992,5997],{"type":21,"tag":111,"props":5964,"children":5965},{"style":164},[5966],{"type":26,"value":1098},{"type":21,"tag":111,"props":5968,"children":5969},{"style":228},[5970],{"type":26,"value":5787},{"type":21,"tag":111,"props":5972,"children":5973},{"style":164},[5974],{"type":26,"value":167},{"type":21,"tag":111,"props":5976,"children":5977},{"style":272},[5978],{"type":26,"value":5979},"'error'",{"type":21,"tag":111,"props":5981,"children":5982},{"style":164},[5983],{"type":26,"value":188},{"type":21,"tag":111,"props":5985,"children":5986},{"style":170},[5987],{"type":26,"value":173},{"type":21,"tag":111,"props":5989,"children":5990},{"style":164},[5991],{"type":26,"value":167},{"type":21,"tag":111,"props":5993,"children":5994},{"style":180},[5995],{"type":26,"value":5996},"err",{"type":21,"tag":111,"props":5998,"children":5999},{"style":164},[6000],{"type":26,"value":216},{"type":21,"tag":111,"props":6002,"children":6004},{"class":113,"line":6003},118,[6005,6009,6013,6017,6022],{"type":21,"tag":111,"props":6006,"children":6007},{"style":164},[6008],{"type":26,"value":4844},{"type":21,"tag":111,"props":6010,"children":6011},{"style":228},[6012],{"type":26,"value":1400},{"type":21,"tag":111,"props":6014,"children":6015},{"style":164},[6016],{"type":26,"value":167},{"type":21,"tag":111,"props":6018,"children":6019},{"style":272},[6020],{"type":26,"value":6021},"'socket:error'",{"type":21,"tag":111,"props":6023,"children":6024},{"style":164},[6025],{"type":26,"value":6026},", err);\n",{"type":21,"tag":111,"props":6028,"children":6030},{"class":113,"line":6029},119,[6031],{"type":21,"tag":111,"props":6032,"children":6033},{"style":164},[6034],{"type":26,"value":1326},{"type":21,"tag":111,"props":6036,"children":6038},{"class":113,"line":6037},120,[6039],{"type":21,"tag":111,"props":6040,"children":6041},{"emptyLinePlaceholder":344},[6042],{"type":26,"value":347},{"type":21,"tag":111,"props":6044,"children":6046},{"class":113,"line":6045},121,[6047,6051],{"type":21,"tag":111,"props":6048,"children":6049},{"style":170},[6050],{"type":26,"value":436},{"type":21,"tag":111,"props":6052,"children":6053},{"style":164},[6054],{"type":26,"value":6055}," socket;\n",{"type":21,"tag":111,"props":6057,"children":6059},{"class":113,"line":6058},122,[6060],{"type":21,"tag":111,"props":6061,"children":6062},{"style":164},[6063],{"type":26,"value":3100},{"type":21,"tag":111,"props":6065,"children":6067},{"class":113,"line":6066},123,[6068,6073,6078],{"type":21,"tag":111,"props":6069,"children":6070},{"style":164},[6071],{"type":26,"value":6072},"})(app ",{"type":21,"tag":111,"props":6074,"children":6075},{"style":118},[6076],{"type":26,"value":6077},"/* replace with your global app object */",{"type":21,"tag":111,"props":6079,"children":6080},{"style":164},[6081],{"type":26,"value":6082},", Backbone, Backbone.Marionette, jQuery, _, io);\n",{"type":21,"tag":22,"props":6084,"children":6085},{},[6086],{"type":26,"value":6087},"As always, comments are appreciated.",{"type":21,"tag":6089,"props":6090,"children":6091},"style",{},[6092],{"type":26,"value":6093},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":8,"searchDepth":133,"depth":133,"links":6095},[],"markdown","content:ckeefer:2014-6:backbonesocketsync.md","content","ckeefer/2014-6/backbonesocketsync.md","ckeefer/2014-6/backbonesocketsync","md",{"user":6103,"name":6104},"ckeefer","Christopher Keefer",1780330271116]