我有一个App.WidgetView负责设置和渲染一个非常昂贵的 3rd 方 ui 元素,我们称之为 ui 元素widget。这widget有一个refresh()方法。我定义了一个refreshWidget()方法,App.WidgetView其中调用widget.refresh().
App.WidgetView = Em.View.extend({
    content: null,
    widget: null,
    init: function () {
        this._super();
        //initialize widget using content
    },
    refreshWidget: function () {
        this.get('widget').refresh();
    }
}); 
我WidgetView使用#each循环从App.widgetController
{{#each App.widgetController}}
    {{view App.WidgetView contentBinding="this"}}
{{/each}}
现在我需要有一个refreshAll()方法,App.widgetController我不太清楚如何干净地做到这一点。现在,我有一个refresher属性,每次调用时都会在App.widgetController其中开始并入罪。0refreshAll
App.widgetController.reopen({
    refresher: 0,
    refreshAll: function () {
        this.incrementProperty('refresher');
    }
});
然后App.WidgetView有一个refresherBinding绑定到的App.widgetController.refresher和一个观察者,它refreshWidget
在refresher变化时调用
App.WidgetView.reopenClass({        
    refresherBinding: 'App.widgetController.refresher',
    refresherChanged: function () {
        this.refreshWidget();
    }.observes('refresher')
});
它确实有效,但我想知道是否有更清晰的方法来做到这一点。