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: 
eberon
Visitor

Slight delay pattern for roSearchScreen?

Hello,

Total newbie here, guys!

Can anyone think of a pattern that would let me delay execution for a little while after a user has entered a character on roSearchScreen?

If I were at my day job programming a web application I would set an asynchronous timeout as soon as a key was pressed, then cancel the timeout if another key was pressed and re-set it again. If the timeout were reached, I would go ahead and execute a search.

I'm trying to be sensitive to the fact that I don't own the service I'm programming against, so I can never truly know how performant it will be or how tolerant they would be of several requests in rapid succession from the same client, from my program.

If no one is worried about this and everyone is implementing calling out to the Internet as soon as a "key" is pressed on roSearchScreens, that's fine and good to know, but I thought I'd ask...

Thanks!
0 Kudos
1 REPLY 1
TheEndless
Channel Surfer

Re: Slight delay pattern for roSearchScreen?

I typically use a very low wait time (250ms), record the isPartialResult() in a variable, then act on that partial result on the next "invalid" event. That essentially introduces a 250ms delay between the last letter selection and calling out to the API, and allows for letters entered in rapid succession to stack instead of queuing up for multiple API queries (i.e., one api.Search() call for "test" instead of four for "t", "te", "tes", and "test"). You could adjust that wait time up or down depending on your preference for delay.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
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.