Toran Billups
Toran Billups

Reputation: 27407

How to trigger a computed property using the global ember-data store?

App.FooController = Ember.ObjectController.extend({
    available: function() {
        var all = this.store.all('bar');
    }.property()
});

When another model "bar" is added to the global ember-data store, how can I trigger the property to recalculate?

I'm using the latest stable ember 1.1.2 and ember-data 1.0 beta 3

Upvotes: 1

Views: 1262

Answers (1)

Kingpin2k
Kingpin2k

Reputation: 47367

All is an active filter, meaning it should update on it's own. Additionally calling all multiple times will return the same 'filtered' array. If you need a different computed property to depend on it you can use each:

App.FooController = Ember.ObjectController.extend({
    available: function() {
        return this.store.all('bar');
    }.property(),

    someTriggerProperty: function(){

    }.property('available.@each')
});

I'm low on sleep so maybe I'm missing something, or failing to explain something correctly. Here's an example, could you show me a portion I'm thinking of incorrectly:

http://emberjs.jsbin.com/OLaYOPI/1/edit

Upvotes: 1

Related Questions