"Veeta" wrote:
Yes, you need to create a Task node and read from the registry in its background thread. It is a little verbose.
"tar" wrote:
Hello everyone,
What is a correct way of using roRegistrySection inside scene graph components?
Per docs, roRegistrySection can be accessed from TaskNodes only.
Do I really have to create asynchronous task nodes and content node subclasses with my custom fields for each registry usage?
Is there a way to at least create a synchronous task node so I don't have to wire up all these observers and deal with multithreading complexity for such a simple task?
Are there any other synchronous persistent storage alternatives for scene graph?
Any help to simplify that out would be greatly appreciated.
"softworkz" wrote:
I solved it like this:
- I'm storing my settings in my own AA
- To make the data available everywhere in the channel, store this data as a field in the global node
- To persist the data, I'm saving it as a JSON string in a single roRegistry string value
- At app start, I load it with a task and wait for completion
- Now all read operations can be performed synchronously by returning data from the AA
- For write operations, I create a task to save to roRegistry, but I don't need to wait for the task to complete, because the AA already has the "latest" data
- This way, all registry operations can be performed synchronously, just like before..
"EnTerr" wrote:
Well done!
Except why run a task to read the registry on start? Just read it in main(), before getting in the event loop.
Prior to creating an roSGScreen object and calling its show() function, creating roSGNode objects and using their interfaces is not guaranteed to work correctly.
"softworkz" wrote:
Found it: https://sdkdocs.roku.com/display/sdkdoc/roSGNode states:Prior to creating an roSGScreen object and calling its show() function, creating roSGNode objects and using their interfaces is not guaranteed to work correctly.
"EnTerr" wrote:
In other words you mustn't create new tasks before you show the scene!