2 var MoreRouting = scope.MoreRouting = scope.MoreRouting || {};
3 MoreRouting.Params = Params;
6 * A collection of route parameters and their values, with nofications.
8 * Params prefixed by `__` are reserved.
10 * @param {!Array<string>} params The keys of the params being managed.
11 * @param {Params=} parent A parent route's params to inherit.
14 function Params(params, parent) {
15 var model = Object.create(parent || Params.prototype);
16 // We have a different set of listeners at every level of the hierarchy.
17 Object.defineProperty(model, '__listeners', {value: []});
19 // We keep all state enclosed within this closure so that inheritance stays
20 // relatively straightfoward.
22 _compile(model, params, state);
26 Params.prototype = Object.create(MoreRouting.Emitter);
30 function _compile(model, params, state) {
31 params.forEach(function(param) {
32 Object.defineProperty(model, param, {
36 set: function(value) {
37 if (state[param] === value) return;
39 model.__notify(param, value);