简体   繁体   English

如何使用全局余烬数据存储触发计算属性?

[英]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 我正在使用最新的稳定余烬1.1.2和ember-data 1.0 beta 3

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 http://emberjs.jsbin.com/OLaYOPI/1/edit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM