Sane way of doing arbitrary/dynamic Query Parameters?


#1

I’ve run into a scenario where I don’t know what queryParams to put on my heavily data-driven route until after the model hook is complete. As far as I can tell, Ember doesn’t natively let you do this.

The gist of it is I’m looking for some sane way of either:

  • hackifying the queryParams hash after loading the model, or
  • just accepting whatever-the-heck parameters I pass to transitionTo.

The closest I’ve been able to Google is this Stack Overflow answer in which the OP conceded to base64-encoding the set of parameters and shoving them in a generically named bucket, which is pretty icky.

Now, reading arbitrary query parameters is easily doable, turns out. I just can’t figure out how to set them.

Any thoughts? How far into feature-request-ville are we?


#2

Fair warning, there are a number of query paean bugs in Ember at the moment. This addon (https://github.com/knownasilya/ember-query-params/blob/master/README.md) may get you part of the way toward what you want, but you’re definitely headed off the beaten trail from what I can see.


#3

Thanks for the linkage, but to be frank, It’s difficult to make heads or tails of that addon’s (sparse) docs. I sorta kinda get what it does, but just barely.

From poking around in the source for ember-query-params, I can’t tell if there’s any magic in the autoSubscribe mixin that would actually tell it to work with “unlisted” (i.e. not-declared-in-controller) parameter keys, which is basically what I’m after. I suppose I could play around with it, but the outlook is dodgy.

[Side-note: I did end up implementing the base64-encoding workaround so I can proceed on my project in the meantime, but doggamn that results in some ugly URLs. ;]