Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
shaharbad
Channel Surfer

How to wait a function finishes and pass variable between files in Roku BrightScript

I'm building a Roku channel and I'm facing a problem where I need a function to finish in order to run the lines afterwards & also I cant figure how to access a variable between components, this is the flow I have:

file1.brs

MainFunction.observeField("itemSelected", "func1") -first wait for this to finish
MainFunction.observeField("itemSelected", "func2") -then run this

sub func2()
    print var1
end sub

file2.brs

sub func1()
    var1 = (get content from some database)
end sub

 

0 Kudos
1 REPLY 1
NoobTube
Reel Rookie

Re: How to wait a function finishes and pass variable between files in Roku BrightScript

How about observing the var1 inside func1() and when it got some value execute func2()? 

0 Kudos
Community Upgrade Coming Soon!

We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. Read more here.

Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 12, or you may notice reduced functionality. In the meantime, for additional assistance, visit our Support Site.

Thanks for your patience — we’re excited to share what’s next!