Computed Properties
Dynamic, cached, properties that can return any CFML data type.
Computed Properties are dynamic properties and are helpful for deriving values from a database or another persistent store like a cache.
Computed Properties are similar to Data Properties with some key differences:
They are declared as inline functions using computed.
They can return any CFML data type, not just values that can be parsed by JavaScript like Data Properties.
Defining Properties
You can define Computed Properties on your components using computed.
Accessing Properties
You can access Computed Properties in your component template using propertyName().
You can also access Computed Properties from within your Actions.
Computed Properties are defined as a CFML closure. That means that to get the result from the function, you must invoke it like so.
Caching
Computed Properties are cached for the lifetime of the request. If you reference your Computed Property three times in your component template or from within a component action, it will only execute once.
You can prevent caching on a computed property by passing a false argument when invoking it.
Last updated