Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
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.

0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.