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

Fixing composer issue where it doesn't respect check() always disposes #781

Closed
wants to merge 1 commit into from

Conversation

mkcode
Copy link

@mkcode mkcode commented Mar 20, 2014

Chaplin's composer is not respecting the check method and is always disposing regardless. Simply using the check method to determine if a composition is stale or not works great for me.

The long form example here: http://docs.chaplinjs.org/chaplin.composer.html does not work as described before this PR.

@mkcode
Copy link
Author

mkcode commented Mar 20, 2014

With regard to #779 - I think we would want to use the check method as it was intended rather than introducing new API points. It seems more robust to me than a @share method on the controller - all of the compose properties are available inside the check method to use.

Also - I could not get the mocha tests running on my machine. Tests will follow if this gets some positive feedback.

@paulmillr
Copy link
Contributor

The example is wrong — it should say model.id isnt 42, not is.

Works for me:

i = 0
class cls extends Chaplin.Model
  initialize: ->
    @subscribeEvent 'a', =>
      i += 1
      @set 'a', i

    @reuse 'stuff',
      compose: ->
        console.log 'compose'
        @model = new cls
      check: ->
        console.log 'check', @model.get('a')
        @model.get('a') isnt 3


[Log] compose (app.js, line 250)
[Log] check undefined (app.js, line 254)
> Chaplin.mediator.publish('a', 1)
< Object

[Log] check 1 (app.js, line 254, x3)
> Chaplin.mediator.publish('a', 1)
< Object

[Log] check 2 (app.js, line 254, x3)
> Chaplin.mediator.publish('a', 1)
< Object

[Log] check 3 (app.js, line 254)
[Log] compose (app.js, line 250)

@paulmillr paulmillr closed this Mar 23, 2014
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.

2 participants