How to observe several query parameters in Ember.js using query-params-new , without explicitly listing each of them in observes() or property() .
Let's say I have the following list of query parameters:
queryParams: [ 'first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth' ], first: null, second: null, third: null, fourth: null, fifth: null, sixth: null, seventh: null, eighth: null, ninth: null, tenth: null
I would like to have a method in the controller that respects all these properties, but without having to list them, for example:
something: function() { ... }.property('first', 'second', 'third', ...)
Edit:
I looped around the queryParams array and set the observer for each of them in the corresponding property:
init: function () { this._super(); var queryParams = this.get('queryParams'); var self = this; queryParams.forEach(function (param) { self.addObserver(param, self, 'updateSelectedOptionsIfQueryParamsChange'); }); },
He works as intended. Is there a better way to do this, or is it right?