Computed Properties
This plugin allows users to specify a path in the data-model (binding) as a computed property in the schema. Anytime this binding is read from, the given expression will be evaluated and returned instead of the it being read from the actual model. Writes to the binding will be prevented, and an error will be thrown.
Usage
Add the plugin to Player:
CocoaPods
Add the subspec to your Podfile
Swift Usage
This plugin takes no parameters, and the configuration comes from content, it can just be added to the plugin array:
Expression Data Type
The computed properties plugin introspects the schema, looking for any DataType
that uses the Expression
:
Any data-lookup for that binding path will evaluate the given expression and return that value. Results are not cached, and will be recomputed on every fetch.
Example
Using the above schema, any reference to {{foo.computedValue}}
will compute the 1 + 2 + 3
expression and use that as the underlying value for that path.
Any write or set operation to {{foo.computedValue}}
will result in a thrown exception for writing to a read-only path.