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