I've just been experemeing with creating the notion of a base scene.. I think that's what I'll go with.
* 1 Screen and 1 scene as per the best practices (some Roku engineer recommends this in a post here, which I stumbled upon
* Base class for my scenes (which are actually groups) - this seems to be working well so far and will allow me to remove some annoying boilerplate.
The next bit I really want to work out is how best to do network/async stuff. I know the pattern of have a task and communicate with it; but that just seems bloody tedious.. My current thinking is a global util network call function, which is async and invoked with the call method which includes in it's payload the name of the current scene - the listener for this util method will then look up the relevant scene, and invoke it's OnURLRequestResult interface method (again via interface functions) with the payload...
That to me seems the most sensible approach I've yet come across - would love to here what other's do.. bummer that there is no real component inheritance. My base methods are essentially placeholders. One does wonder what this platform would've been like with Python/C# as the language, I must confess.
Anyone see a problem with this approach btw?
'ThirdScene.brs
function init()
? "[THIRD SCENE]"
end function
'***********************************
' Key handler overrides
'***********************************
function OnPressOk() as boolean
? "PRESSED OK"
return true
end function
function OnPressDown() as boolean
? "PRESSED DOWN"
return true
end function
function OnPressUp() as boolean
? "PRESSED UP"
return true
end function
'BaseScene.brs
function init()
? "[BASE SCENE]"
end function
function onKeyEvent(key as String, press as Boolean) as Boolean
result = false
if press then
if key = "left" then
result = OnPressLeft()
else if key = "right" then
result = OnPressRight()
else if key = "up" then
result = OnPressUp()
else if key = "down" then
result = OnPressDown()
else if key = "OK" then
result = OnPressOK()
end if
end if
return result
end function
'***********************************
' Key handler abstract methods
'***********************************
function OnPressLeft() as boolean
return false
end function
function OnPressRight() as boolean
return false
end function
function OnPressUp() as boolean
return false
end function
function OnPressDown() as boolean
return false
end function
function OnPressOK() as boolean
return false
end function
George Cook
https://georgejecook.github.io/
https://linkedin.com/in/georgejecook/
Roku developers slack group (https://join.slack.com/t/rokudevelopers/shared_invite/zt-4vw7rg6v-NH46oY7hTktpRIBM_zGvwA) : georgejecook
Contact me on roku developer slack group, or via pm to discuss consultancy/work opportunities/rooibos unit testing framework