Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
EnTerr
Level 11

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>
0 Kudos
4 REPLIES 4
RokuKC
Roku Employee
Roku Employee

Re: roSgNode implements 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.
0 Kudos
EnTerr
Level 11

Re: roSgNode implements ifAssociativeArray ?

"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 🙂
0 Kudos
RokuKC
Roku Employee
Roku Employee

Re: roSgNode implements ifAssociativeArray ?

"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().
0 Kudos
EnTerr
Level 11

Re: roSgNode implements ifAssociativeArray ?

"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>
0 Kudos