Computed Properties
Dynamic, cached, properties that can return any CFML data type.
Computed Properties are dynamic properties that help derive values from a database or another persistent store, such as a cache.
Computed Properties are similar to Data Properties with some key differences:
They are declared as functions within your component with a
computed
attribute added.They are cached.
They can return any CFML data type, not just values that can be parsed by JavaScript like Data Properties.
Computed properties are meant to return values and not change state such as modifying Data Properties. If you need to update a data property, use Actions instead.
Defining Computed Properties
You can define Computed Properties on your components as functions with the computed
attribute added.
Accessing Computed Properties
You can access Computed Properties in your component template using propertyName().
You can also access Computed Properties from within your Actions.
Caching
Computed Properties cache their results for the lifetime of the request. It will only execute once if you reference your Computed Property three times in your component template or from within a component action.
You can prevent caching on a computed property by passing a false argument when invoking it.
Last updated