Skip to content

Instantly share code, notes, and snippets.

@acidsound
Created October 4, 2012 21:08
Show Gist options
  • Save acidsound/3836472 to your computer and use it in GitHub Desktop.
Save acidsound/3836472 to your computer and use it in GitHub Desktop.
use JSON Object on Meteor.Session
/* getter/setter limit for page */
var getLimit = function (page) {
try {
pageLimit = JSON.parse(Session.get('limit'))[page];
pageLimit = pageLimit ? pageLimit : DEFAULT_PAGE_LIMIT;
return pageLimit;
} catch (e) {
return DEFAULT_PAGE_LIMIT;
}
}
var setLimit = function (page, limit) {
try {
pageLimit = JSON.parse(Session.get('limit'));
} catch (e) {
p = {};
p[page] = limit;
Session.set('limit', JSON.stringify(p));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment