AmpersandJS / ampersand-events

Standalone event system that can be mixed into any object
MIT License
18 stars 7 forks source link

Can ampersand-events be used in place of Backbone.Events? #9

Closed dschissler closed 9 years ago

dschissler commented 9 years ago

I'm considering using all Ampersand modules and creating a fake backbone module with the following so that I can use backbone.radio.

module.exports = {
    Events: require('ampersand-events')
}

Will this work?

latentflip commented 9 years ago

It's pretty similar to Backbone.Events and so should support the same methods.

Have you tried it?

dschissler commented 9 years ago

No but I'm near to doing it. It will take me some hours to convert my Marionette R&D skeleton to Ampersand (to port some old pure Backbone code). I'm considering just using Events.createEmitter() since I don't think that I need multiple channels.

getdave commented 9 years ago

@dschissler did you ever use Radio with ampersand?

dschissler commented 9 years ago

No. I might try that soon since my code has settled down a bit since all of the structure is ampersand now. I'll let you know about that.

getdave commented 9 years ago

@dschissler That would be great. I really like Backbone Radio and so being able to utilise with Ampersand would be a big win.

dschissler commented 9 years ago

@getdave Sorry for the long delay. The backend took a long time. So far it seems to be wiring up well with:

backbone_shim user module

'use strict';
import Events from 'ampersand-events';

export default {
  Events: Events
}

webpack config

    alias: {
      underscore: 'lodash',
      backbone: 'backbone_shim',
      ...
    },

globalCh user module

'use strict';
import Radio from 'backbone.radio';

export default Radio.channel('global');

I think that its best to use a globalCh module because you can wire it up with different libraries.