0
votes

I have a simple property on my controller. It's used to render a list of all the emails in a conversation.

conversation: (->
  App.Email.filter (otherEmail) => 
    @get('model').isIncludedInConversation otherEmail
).property('model')

Everything works fine and dandy when I go to the page because the CP hasn't been computed yet. When I send a new email the conversation property is not updated. I need to switch what email I'm looking at to trigger conversation to recalculate.

I know the filter is being updated. The problem is the CP's value does not change and the underlying {{#each conversation}} is not updated. How can I make this work?

EDIT: I've added fiddle here: http://jsfiddle.net/twinturbo/GUeE3/1/

1
where is otherEmail coming from? shouldn't it be a property dependency? - MilkyWayJoe
@MilkyWayJoe it's passed by the filter function to the callback used to filter github.com/emberjs/data/blob/master/packages/ember-data/lib/… - Cyril Fluck

1 Answers

1
votes

I'm not familiar with coffeescript, so I assume that your code is equivalent to:

conversation: function() {
  var self = this;
  App.Email.filter( function( otherEmail ) {
    return self.get('model').isIncludedInConversation( otherEmail );
  }); 
)}.property('model')

I would be tempted to say that you should capture model outside the filter function

conversation: (->
  _model = @get('model')
  App.Email.filter (otherEmail) => 
    _model.isIncludedInConversation otherEmail
).property('model')

This code works for me with the latest version of ember and ember data.