What is the first argument in the register method using FlowRouter?


I have finally wrapped my head around FlowRouter to some extent but in the ‘subscription’ method I’m uncertain as to what the first argument in the register function is.

For example on @arunoda FlowRouter repo in he uses this example:

FlowRouter.route('/blog/:postId', {
    subscriptions: function(params) {
        console.log("subscribe and register this subscription as 'myPost'");
        this.register(**'myPost'**, Meteor.subscribe('blogPost', params.postId));
    action: function(params) {
        console.log("Yeah! We are on the post:", params.postId);

What i don’t understand about it is where the ‘myPost’ argument is coming from. Is that the name of the template in which the collection subscribed to will render to?


It’s just a keyword to name your subscription. You can refer it later on using FlowRouter.subsReady()


@arunoda thank you I found that by following [this][1] article. I just had another question if I have a block like this

<template name="ListCards">
>         {{#if isSubReady 'cards'}}

>         	{{#each getCards}}
>         	  {{> CreditCardNav}}
>         	  {{> CreditCardContent}}
>         	{{/each}}

>        {{else}}
>     	Loading...
>        {{/if}}
> </template>

will my templates that are wrapped in the #each loop “CreditCardNav” and “CreditCardContent” and the other nested templates within those templates still have access to the ‘cards’ collection so that they can render properties or should I NOT abstract other templates outside of this particular template because then the helper of this template wouldn’t work on the nested templates?

My app isn’t throwing errors it’s just that my collection never gets pulled in but rather I get the 'Loading…" on the screen instead of the collection.

Here are my ‘ListCards’ helpers:

	isSubReady: function(sub) {
		if(sub) {
			return FlowRouter.subsReady(sub);
		} else {
			return FlowRouter.subsReady();
	getCards: function() {
		return Cards.find({});

Note: I have 4 records in the collection and here is the route:


FlowRouter.route('/account/billing_information', {
		subscriptions: function(params, queryParams) {
		this.register('cards', Meteor.subscribe('allCreditCards'));
	action: function(params, queryParams) {
		FlowLayout.render('MasterLayoutUsers' , {top: 'Header' , main: 'BillingTab' , bottom: 'Footer'});
	name: 'billingTab' //pathFor value

Here is the publication within server/publications.js

Meteor.publish('allCreditCards', function(){
	return Cards.find({});

and here is the collection lib/collections/Cards.js

Cards = new Mongo.Collection("cards");

Thank you.
[1]: http://massimilianomarini.com/flowrouter-and-flowlayout-101/