kadirahq / flow-router

Carefully Designed Client Side Router for Meteor
MIT License
1.09k stars 195 forks source link

Feature request: setDefaultParam and setDefaultQueryParam/Params #589

Open AlexFrazer opened 8 years ago

AlexFrazer commented 8 years ago

Similar to Session.setDefault. Basically a set if not set behavior.

My common use case is for a List component, where it has a series of default options that I want to try to set, if they are not already set.

import {FlowRouter} from "meteor/kadira:flow-router";
import {BlazeComponent} from "meteor/peerlibrary:blaze-components";

import "./list.jade";

export const OPTIONS = {
  limit: 10,
  sort: {}
}

export class List extends BlazeComponent {
  onCreated() {
    super.onCreated();
    FlowRouter.setDefaultQueryParams(OPTIONS);
  }
  // rest is not important
}