Book Image

KnockoutJS Web Development

Book Image

KnockoutJS Web Development

Overview of this book

Table of Contents (13 chapters)
KnockoutJS Web Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using a computed observable


A computed observable provides the following functions:

  • dispose(): This manually disposes the computed observable, clearing all subscriptions to dependencies. This function is useful if you want to stop a computed observable from being updated or want to clean up memory for a computed observable that has dependencies on observables that won't be cleaned.

  • extend(extenders): This applies the given extenders to the computed observable.

  • getDependenciesCount(): This returns the current number of dependencies of the computed observable.

  • getSubscriptionsCount(): This returns the current number of subscriptions (either from other computed observables or manual subscriptions) of the computed observable.

  • isActive(): This returns whether the computed observable may be updated in the future. A computed observable is inactive if it has no dependencies.

  • peek(): This returns the current value of the computed observable without creating a dependency.

  • subscribe( callback [,callbackTarget...