With the shared
attribute an instance becomes visible within nested Fore elements.
The data are truly shared - changing the data within a nested Fore will change the original data. This simplifies to delegate the handling of a subtree of elements to a sub Fore without the need to maintain a clone and applying it back.
This example uses an outer Fore element and nests another 2 Fore elements within itself. All share (and modify) the instance 'todos'. The first sub Fore just lists the entries but adds 'You can do it!', the second mirrors the same repeat as its parent.
Refresh of nested Fore elements in a shared scenario only propagate downwards. Making changes in a child won't automatically show up
in the parent but happen on next refresh cycle. If you want to immediately update
you can dispatch an refresh
event to the parent which will refresh itself then. See child-b which dispatches a refresh
whenever
value changes.
Caution: instance ids are not resolved in any way by now, so you have to make sure that ids that unique within a composed page.
{.} - {instance('default')/message}