You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the purposes of the description here, the term BindableValue will act as a union type of either:
a primitive, like a string, int or float.
an object with a __toString function.
The term BindableData will act as a union type of either:
an associative array of key-values, where the values are of type BindableValue.
an object with public properties, acting as key-values.
an object that implements the BindDataGetter or BindDataMapper interfaces.
The bind function will make a call to the following bind functions, depending on the parameters passed into it:
bindValue(BindableValue $value) - binds any element(s) in the tree that has a data-bind:X attribute without a key name.
bindKeyValue(string $key, BindableValue $value) - binds any element(s) in the tree that has a data-bind:X=Y attribute, where Y matches $key.
bindData(BindableData $data) - calls bindKeyValue for every key-value-pair of $data.
bindList(iterable $list) - creates a template element for each iteration, and calls bindData on the template element, passing the value of the iterator. This functionality is broken down below.
Breaking down bindList
The iterable$list is bindList's only parameter, but its contents can determine the function's behaviour (sometimes recursive).
For every iteration of the iterable, a new template element is cloned. The first extracted template element that matches the current context element's nodePath is used as the template element.
Once a template element has been cloned, bind functions will be applied to it. If the $list is an associative array (or anything other than an indexed array/iterator), the key is passed to bindValue on the current template element.
If the value is a BindableValue, the value is passed to bindValue. Therefore, an associative array of strings would not be a valid $list, and an exception must be thrown.
If the value is a BindableData, the value is passed to bindData.
If the value is iterable, the value is passed to bindList again (recursively), but the context node shifts to the newly cloned template.
The text was updated successfully, but these errors were encountered:
For the purposes of the description here, the term
BindableValue
will act as a union type of either:string
,int
orfloat
.__toString
function.The term
BindableData
will act as a union type of either:BindableValue
.BindDataGetter
orBindDataMapper
interfaces.The
bind
function will make a call to the following bind functions, depending on the parameters passed into it:bindValue(BindableValue $value)
- binds any element(s) in the tree that has adata-bind:X
attribute without a key name.bindKeyValue(string $key, BindableValue $value)
- binds any element(s) in the tree that has adata-bind:X=Y
attribute, whereY
matches$key
.bindData(BindableData $data)
- callsbindKeyValue
for every key-value-pair of$data
.bindList(iterable $list)
- creates a template element for each iteration, and callsbindData
on the template element, passing the value of the iterator. This functionality is broken down below.Breaking down bindList
The
iterable
$list
isbindList
's only parameter, but its contents can determine the function's behaviour (sometimes recursive).For every iteration of the iterable, a new template element is cloned. The first extracted template element that matches the current context element's nodePath is used as the template element.
Once a template element has been cloned, bind functions will be applied to it. If the
$list
is an associative array (or anything other than an indexed array/iterator), the key is passed tobindValue
on the current template element.If the value is a
BindableValue
, the value is passed tobindValue
. Therefore, an associative array of strings would not be a valid $list, and an exception must be thrown.If the value is a
BindableData
, the value is passed tobindData
.If the value is
iterable
, the value is passed tobindList
again (recursively), but the context node shifts to the newly cloned template.The text was updated successfully, but these errors were encountered: