Ember & paged API, page_size from session cookie

Happy 2016 to everyone!

I am using a paged API for my tiny Ember project. Therefore I added a parameter ‘page_size’ to my controllers which is initialized with - let’s say - 10 (entries per page). Works like a charm.

As the user can choose another value (50 or 100), I want to persist user’s decision. Maybe in a cookie? How do I init page_size from a cookie value? Is there a better way?



In case someone is interested in… I solved the problem with ‘ember-local-storage’, moved the init of ‘page_size’ from controller to route.

extractPageSize: function (params) {
    if (Ember.isPresent(params.page_size)) {
        return parseInt(params.page_size);
    else {
        return parseInt(this.get('settings.page_size'));

model: function (params) {
    return Ember.RSVP.hash({
        page_size: this.extractPageSize(params)

setupController: function (controller, model) {
    controller.set('page_size', model.page_size);