Skip to content

Commit

Permalink
Added connect/disconnect callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Wildhoney committed Nov 12, 2013
1 parent 7572dce commit f932073
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dist/ember-sockets.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions example/js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
// Update the property using a callback.
cherryPickedName: function(name) {
this.set('name', name);
},

// When EmberSockets makes a connection to the Socket.IO server.
connect: function() {
console.log('EmberSockets has connected...');
},

// When EmberSockets disconnects from the Socket.IO server.
disconnect: function() {
console.log('EmberSockets has disconnected...');
}

},
Expand Down
5 changes: 5 additions & 0 deletions package/ember-sockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@

if (controller) {

// Invoke the `connect` method if it has been defined on this controller.
if (typeof controller.sockets === 'object' && typeof controller.sockets.connect === 'function') {
controller.sockets.connect.apply(controller);
}

// Iterate over each event defined in the controller's `sockets` hash, so that we can
// keep an eye open for them.
for (var eventName in eventNames) {
Expand Down

0 comments on commit f932073

Please sign in to comment.