Skip to content

Instantly share code, notes, and snippets.

@machty
Forked from lukemelia/query-param-ideas.js
Last active December 30, 2015 05:18
Show Gist options
  • Save machty/7781260 to your computer and use it in GitHub Desktop.
Save machty/7781260 to your computer and use it in GitHub Desktop.
FooController = Em.Controller.extend({
queryParamBindings: ['bar'], // maps to foo[bar]
bar: 'baz',
widgets: Ember.computed.sort('content', 'bar')
});
FooController = Em.Controller.extend({
queryParamBindings: ['bar:lalal'], // maps to lalal
bar: 'baz',
// it should be very rare to have to configure this,
// but we need some hook to enable pushState changes
historyType: function(paramName, value) {
if (paramName) {
return HISTORY.REPLACE_STATE;
}
}
})
FooRoute = Em.Route.extend({
model: function(params) {
// all params
return getAThing(params);
},
actions: {
// There is a default implementation of queryParamsDidChange,
// see below.
queryParamsDidChange: function(changedParams){
this.refresh();
}
}
});
FooRoute = Em.Route.extend({
refreshOnQueryParamChanges: ['bar', /^foo/]
model: function(params) {
return FooDataAccess.retrieveFoos(paramsToFooSelectionData);
},
});
Em.Route#refresh // schedules re-run of the model hooks of this route
// which the run loop coalesces to refresh routes in an intelligent order (root-iest on down to leaf-iest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment