Book Image

Mastering KnockoutJS

By : Timothy Moran
Book Image

Mastering KnockoutJS

By: Timothy Moran

Overview of this book

Table of Contents (16 chapters)
Mastering KnockoutJS
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The application's life cycle


Durandal's composition and activator services allow optional callbacks to control or hook into their life cycles. They can be useful when performing setup and teardown, or implementing logic to block or redirect page changes.

The activation life cycle

An activator is a special computed observable, whose write function enforces the activation life cycle. Unless you are managing composition or routing yourself, the only activators you will work with are the ones used by the router and the dialog system. Though, if you are interested, you can create your own activator by requiring in the durandal/activator module and using the create function.

The following optional properties are called by the activator when the active value tries to change:

  • canActivate: This is called on the new value; it should return either a Boolean or a promise that resolves to a Boolean. If the result is false, activation is cancelled.

  • activate: This is called on the new value after canActivate...