Wildhoney / EmberSockets

Socket.io (WebSockets) integrated with Ember.js' observer pattern.
http://ember-sockets.herokuapp.com/
MIT License
136 stars 22 forks source link

EmberSockets dont send events for controllers without "actions" property #5

Closed felipehw closed 10 years ago

felipehw commented 10 years ago

In my tests a controller only receive events from the server if we set the actions property in the controller (we can set a empty object).

If i make a controller without the actions property, the things in the events hash don't work.

For example:

Work:

export default Ember.ArrayController.extend({
  actions: {},
  events: {
    // 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...');
    },
  }
});

Dont work:

export default Ember.ArrayController.extend({
  events: {
    // 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...');
    },
  }
});
Wildhoney commented 10 years ago

Thanks!

I think it was caused because events was used by Ember in the past at some point. I don't remember ever having to use it – I thought it went straight from nothing to actions, but because Ember raises a warning about the events object if actions is undefined, then I think it was overwriting it, thus removing everything that you defined on events for EmberSockets.

As a result I've had to change the events object back to sockets, and as such bumped the version fo 0.4.0. Will update the README accordingly.

felipehw commented 10 years ago

Thanks for the fix!