Forum Discussion
Veeta
9 years agoVisitor
"malort" wrote:"Veeta" wrote:
There is a new API in 7.6 that I'm hopeful will address this: ifSGNodeField.update. In my experience, anything that can be done natively (vs. in BRS code) is a huge performance boost. ifSGNodeField.update should be able to take ParseJSON output and convert it into a node tree in one call.
Yeah, that could definitely be a useful performance boost to convert nodes containing roArray/roAA into nodes, but there are still some limitations there.
- The initial roAA won't be able to contain functional fields, unlike creating a custom node directly. This is the key benefit we've been looking for. If only RSG has first-class function support.
- You still need to set the roArray/roAA to a content node (deep-copy), then you can call node.Update() to convert the children.
Your second point is not correct. You pass the source AA as an argument to update(). The following works for me on 7.6:
Brightscript Debugger> a = { children: [ { id: "item1" }, { id: "item2" } ] }
Brightscript Debugger> print a
<Component: roAssociativeArray> =
{
children: <Component: roArray>
}
Brightscript Debugger> u = CreateObject("roSGNode", "ContentNode")
Brightscript Debugger> u.update(a)
Brightscript Debugger> print u
<Component: roSGNode> =
{
change: <Component: roAssociativeArray>
focusable: false
focusedChild: <Component: roInvalid>
id: ""
}
Brightscript Debugger> print u.getchildcount()
2
Brightscript Debugger> print u.getchild(0)
<Component: roSGNode> =
{
change: <Component: roAssociativeArray>
focusable: false
focusedChild: <Component: roInvalid>
id: "item1"
}