Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Conversation

@albatrocity
Copy link

delegateListeners and delegateListener have been moved to the EventBroker so that all classes that mix it in can define a listen object to define event listeners. The delegateListeners method is called in the constructor of Views, Models, Collections, and Controllers. Basically applying #419 to the other basic Chaplin classes.

The motivation behind this was so I could do:

class ThingController extends Controller
  listen:
    'saveThing mediator': 'update'

  update: (model) ->
    model.save
      success: =>
        @redirectTo 'things'

instead of:

class ThingController extends Controller
  initialize: ->
    super
    @subscribeTo 'saveThing', @update

  update: (model) ->
    model.save
      success: =>
        @redirectTo 'things'

I do this a lot and overriding initialize was starting to feel dirty 😄

@Sija
Copy link
Contributor

Sija commented Apr 26, 2014

👍

@jeron-diovis
Copy link

Oh, it's cool! Let's be more declarative.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants