Book Image

Building Single-page Web Apps with Meteor

By : Fabian Vogelsteller
Book Image

Building Single-page Web Apps with Meteor

By: Fabian Vogelsteller

Overview of this book

Table of Contents (21 chapters)
Building Single-page Web Apps with Meteor
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

The iron:router hooks


The following table contains a list of router controller hooks:

action

This function can overwrite the default behavior of the route. If we define this function, we have to manually render the template using this.render().

onBeforeAction

This function runs before the route gets rendered. Here, we can put extra custom actions.

onAfterAction

This function runs after the route gets rendered. Here, we can put extra custom actions.

onRun

This function runs once when the route is first loaded. This function doesn't run again on a hot code reloads or when the same URL is navigated again.

onRerun

This function will be called every time the route is called.

onStop

This function runs once when leaving the current route to a new route.

subscriptions

This function can return subscription(s) that affect this.ready() in the action hooks

waitOn

This function can return subscription(s), but will automatically render the loadingTemplate until those are ready.

data

The return value of this function will be set as the data context of this routes template.

A full explanation of these hooks can be found at the following resources:

  • https://github.com/EventedMind/iron-router/blob/devel/Guide.md#layouts

  • https://github.com/EventedMind/iron-router/blob/devel/Guide.md#hooks

  • https://github.com/EventedMind/iron-router/blob/devel/Guide.md#rendering-templates-with-data