O'Reilly logo

KnockoutJS Web Development by John Farrar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the computed context

During the execution of a computed observable's evaluator function, you can access ko.computedContext to get information about the current computed property. It provides the following functions:

  • isInitial(): This is a function that returns true if called during the first ever evaluation of the current computed observable, or false otherwise. For pure computed observables, isInitial() is always undefined.
  • getDependenciesCount(): This returns the number of dependencies of the computed observable detected so far during the current evaluation.

    Note

    The ko.computedContext.getDependenciesCount() function is equivalent to calling getDependenciesCount() on the computed observable itself. The reason that it also exists on ko.computedContext ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required