Developers

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
xoceunder
Roku Guru

Add a property to each row of content

Add a property to each row of content: state - it's a string it can be none, loading, loaded, failed.
Make arrays: loadingtasks, pending takes and an integer maxLoading
Observe the rowlist currfocus property. When it gets past a row, check the state of the row
If none, then create a task for it.
Attach the row to the task, or a the index of the row being loaded or keep it in a dictionary with the index or Id of the row. Do not start it yet.
If loading tasks array is full (has more tasks than maxLoading), push the task to pending takes array. otherwise push it to loading tasks array and start it.
Observe the tasks output
When the task finishes it has the rowindex of the loaded row. Update it.
Check if you have more tasks to load in pending tasks. If so load one.

This is easy to do with the functions: createTaskForRow(row), startTask(task), getNextPendingTask(), onTaskComplete(). I would make this code generic,
so you can use it on any screen. Personally i like to make rows nodes a bit richer, and have code for them with functions: isLoadRequired(),
and receiveItems()receiveItems is really handy because it can be used to replace loading placeholders with real items and / append more for load more.

Tags (1)
0 Kudos
Community is Being Upgraded!

We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. Read more here.

Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 19th and you may notice reduced functionality. In the meantime, for additional assistance, visit our Support Site.

We're sorry for this disruption — we’re excited to share what’s next!

For support, visit support.roku.com.