I’ve got a login flow working, and after login in successfully, the API I’m using returns an “access token”. Coming from an ObjectOriented approach, I’d just set an object that contains the token and pass that around where ever I needed it. That doesn’t seem to be the paradigm with Roku/ScreenGraph.
Is there anyway to set that token after it’s retrieved, and be able to access it easily in other parts of the program?
You can still pass it around just as OOP thought you, as long as you don’t have to cross threads (main v render v task) - then things get more funky. Still doable but you would have to get rather specific what/where/how you want to pass around
You could set it as a global reference in the main.brs or main thread.
For scenegraph –
screen=CreateObject(“roSGScreen”) 'creates roSGScreen
m.global=screen.getGlobalNode()
m.global.addfield(“token”,“string”,FALSE)
Then to set the variable use
m.global.token=value
Where value is the string you want to place into the global space.
And then you can reference it within any component or routine in the app as m.global.token
Or change it again anywhere in the app with m.global.token=value again