Search code examples
rokubrightscript

What does it mean outside of main in "Do not use Eval() outside of the main() "?


I'm new to roku development and considering using eval but I stumbled upon this warning in the docs

Do not use Eval() outside of the main() function as it can cause unexpected bugs and crashes

Not sure I completely understand the restriction, what do they mean when they say "running outside of main"?


Solution

  • Every Roku application has main.brs file ( You can name this file whatever you want as long as it's located under source folder, Nas Banov pointed out in the comment below that there is no main.brs requirement) and in it you will have Main() function. For example Deep linking is implemented by passing parameters to the Main() function etc. Also this is Roku's main thread (you have Main, SceneGraph and Task thread).

    So what this:

    Do not use Eval() outside of the main() function as it can cause unexpected bugs and crashes

    Actually means is this:

    Do not use Eval outside of main thread as it can cause unexpected bugs and crashes

    More on SceneGraph Threads : https://sdkdocs.roku.com/display/sdkdoc/SceneGraph+Threads