Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
georgejecook
Level 7

Any way to pass return value from extended component function?

I have Component BaseClass extends Group
it has a function SayHello as string

I then extend it with ExtendedClass extends BaseClass
it extends funciton SayHello as string

Is there any way for ExtendedClass to get the SayHello value returned from BaseClass?
George Cook
https://linkedin.com/in/georgejecook/
Roku developers slack group (http://tiny.cc/nrdf0y) : georgejecook

Contact me on roku developer slack group, or via pm to discuss consultancy/work opportunities/rooibos unit testing framework
0 Kudos
3 Replies
Highlighted
joetesta
Level 10

Re: Any way to pass return value from extended component function?

Perhaps you can add two fields to the BaseClass, a boolean that signals BaseClass to run its SayHello function and the other field that receives the value returned by that function.  Then the ExtendedClass could make use of those fields to call and receive the BaseClass SayHello value.
aspiring
0 Kudos
joetesta
Level 10

Re: Any way to pass return value from extended component function?

in BaseClass.xml
<field id="runSayHello" type="boolean" alwaysNotify="true" onChange="onRunSayHello" />
<field id="sayHelloResponse" type="string" />


in BaseClass.brs
sub onRunSayHello()
  m.top.sayHelloResponse = SayHello()
end sub


in ExtendedClass.brs
sub getBaseSayHello()
  m.top.observeField("sayHelloResponse","gotResponse")
  m.top.runSayHello = true
end sub

sub gotResponse()
  print "Response: "; m.top.sayHelloResponse
end sub
aspiring
0 Kudos
georgejecook
Level 7

Re: Any way to pass return value from extended component function?

Thanks,

I use this strategy pattern extensively, in all languages. I was hoping that there'd be a provision for simple overriding; but more widely using deference, as you suggest, is just as good a solution.

Appreciate the code snippets! Thanks!
George Cook
https://linkedin.com/in/georgejecook/
Roku developers slack group (http://tiny.cc/nrdf0y) : georgejecook

Contact me on roku developer slack group, or via pm to discuss consultancy/work opportunities/rooibos unit testing framework
0 Kudos