simple package to add and take parameters in the route with Meteor
$ meteor add cottz:iron-query
Iron.query
works exactly as a session but their values are stored in the route and depend of the route
add or change the value of a key in the path
gets the value of a key in the current path, if not sends key
return an object with all the query keys
is exactly equal to Iron.query.get
but non reactive (that description kills people)
helpers available in the template
gets the value of a key in the current path, this helper uses Iron.query.getNonreactive because in most cases rerunning the helper in the template is not required
is exactly equal to ironQuery
but reactive (captain obvious help me)
add or change the value of a key in the path but without redirect
redirects to the path with the current keys object
to further clarify the above Iron.query.set
is this
Iron.query.set = function (key, value) {
this.wait(key, value);
this.go();
};
Router.route('/home', {
// with fastRender waiton is not very useful so I use subscriptions
subscriptions: function () {
var query = this.params.query;
return [
Meteor.subscribe('news', {
skip: Number(query.skip),
search: query.q
});
];
},
fastRender: true
});
/* somewhere in the client-side */
Iron.query.set('skip', 10);
Iron.query.set('q', 'beautiful places');