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: 
mape
Visitor

Re: Creating RAF instance - in Task and not

"EnTerr" wrote:
Btw, one does not need really to persist the Roku_Ads() result. Calling it repeatedly is "cheap" so just assign it in local variable (e.g. `ads` and not `m.ads`) every time needed.

I try to create Roku-Ads()in the Scene,init(), and got this error:

BRIGHTSCRIPT: ERROR: roAppInfo: class PLUGIN|MARKUP on thread RENDER: roku_ads_lib:/Roku_Ads.brs(560)
BRIGHTSCRIPT: ERROR: roMessagePort: Trying to construct a message port on a non-plugin thread: roku_ads_lib:/Roku_Ads.brs(335)
BRIGHTSCRIPT: ERROR: roUrlTransfer: class PLUGIN|MARKUP on thread RENDER: roku_ads_lib:/Roku_Ads.brs(336)

So, to create Roku_Ads() 'any time' is not so easy 😞
0 Kudos
EnTerr
Roku Guru

Re: Creating RAF instance - in Task and not

"mape" wrote:
"EnTerr" wrote:
Btw, one does not need really to persist the Roku_Ads() result. Calling it repeatedly is "cheap" so just assign it in local variable (e.g. `ads` and not `m.ads`) every time needed.

Really? Sounds good.
But, i think to separate it to the Task will be useful to share it between different Scenes and Players. 

That is already done internally, it is being shared every time you call Roku_Ads(). I.e. RAF is already smart and does not create new instances on each invocation. To throw a buzzword, do you know the "signleton pattern"? RAF is a singleton already.
0 Kudos
mape
Visitor

Re: Creating RAF instance - in Task and not

"EnTerr" wrote:
"mape" wrote:
 

That is already done internally, it is being shared every time you call Roku_Ads(). I.e. RAF is already smart and does not create new instances on each invocation. To throw a buzzword, do you know the "signleton pattern"? RAF is a singleton already.

Got it, thank you. 
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.