iron-meteor / iron-router

A client and server side router designed specifically for Meteor.
MIT License
1.98k stars 413 forks source link

Is it possible to separate hash and query inside reactive params? #1482

Closed escaroda closed 8 years ago

escaroda commented 8 years ago

When I change hash I need to trigger some autorun and when I change query I need to trigger another function but with .getParams() reactivity affects both. Can I separate it? Or I should change Iron Router source code for this?

escaroda commented 8 years ago

Maybe I can add this and it will work? (afraid it couldn't be so simple like this but)

RouteController.prototype.getQuery = function () {
  return this.params.query;
};

RouteController.prototype.getHash = function () {
  return this.params.hash;
};

seems like I need to create new Tracker dependency for hash to call this._paramsHashDep.changed() but can't find where

escaroda commented 8 years ago

Or it will be better to run:

Tracker.autorun(function() {
  var params = Router.current().getParams();
  Session.set('hash', params.hash)
})

And use Session.get('hash') when I need hash reactivity Should work right?

escaroda commented 8 years ago

I've changed link design. I guess it wasn't a good idea to play with hash and query seperately