traverseflow allows a block of code to be executed once for each item in an array, and then for subsequent arrays contained within a specified key, if any. The order of iteration is guaranteed because iteration happens over sourced arrays.
traverseflow loops through nested data recursively, flattening the output. Basic usage of the
traversetag is as follows:
traverseflow is as follows:
key- key of the iterated value within the current context
value- the newly created property where iteration data is stored
source- The source array
traverseflow can be used to flatten nested structures, such as components. Components in Supernova are represented as a tree - parent components such as
viewscan contain many other components (their children). This can go into unlimited depth.
componentTreedefined that contains the following data (a simplified version of Supernova component data model):
componentTreecontains 4 views spread over 3 levels of depth. We can use
traverseflow to allow for this nested iteration:
componentTree- the source dictionary as the first item of iteration and then checks for
componentskey, expecting an array. If an array is encountered, the iteration continues within that leaf of the tree. The generated result will then look like this: