roSgNode implements ifAssociativeArray ?

It seem that roSgNode (AKA everything RSG) implements ifAssociativeArray? Is this intentional and official - or is it a leaky abstraction or subject to change?

Coincidentally i discovered today that a node responds to .count(), then to .doesExist() - and decided to dig futher some more:

BrightScript Debugger> o = createObject("roSgNode", "Node"): ? o
<Component: roSGNode> =
{
    change: <Component: roAssociativeArray>
    focusable: false
    focusedChild: <Component: roInvalid>
    id: 
}

BrightScript Debugger> ? o.count()
 4

BrightScript Debugger> ? o.doesExist("id")
true

BrightScript Debugger> ? getInterface(o, "ifAssociativeArray")
<Interface: ifAssociativeArray>

“EnTerr” wrote:
It seem that roSgNode (AKA everything RSG) implements ifAssociativeArray? Is this intentional and official - or is it a leaky abstraction or subject to change?

It is intentional and official. The SDK docs have been updated now.

“RokuKC” wrote:
It is intentional and official. The SDK docs have been updated now.
Thank you for the direct answer!
Hmmm… this further raises unexpected questions though:

  • What does roSgNode.clear() do? It seems to erase all fields - but what is “all” when there is nested-component inheritance? Also what about the baked-in fields?

  • What does roSgNode.append() do? Is it alias to roSgNode.addFields() mish-mash maker?

PS. I assure you this was not a trick question - when i noticed the .count() works, i thought “ha, roSgNode tighty whities are showing”, i.e. implementation details are leaking out. Turns out it was fashion and jeans were supposed to hang low :slightly_smiling_face:

“EnTerr” wrote:

  • What does roSgNode.clear() do? It seems to erase all fields - but what is “all” when there is nested-component inheritance? Also what about the baked-in fields?

  • What does roSgNode.append() do? Is it alias to roSgNode.addFields() mish-mash maker?

clear() can only delete dynamically added fields.
append() can be considered an alias to addFields().

“RokuKC” wrote:
clear() can only delete dynamically added fields.
Hmm, in my tests it also deletes the static-added fields; as in, this kind:

<interface>
  <field id="foo" type="assocarray" onChange="bar"/>
</interface>