DEV Community

Discussion on: 60fps JS while sorting, mapping and reducing millions of records (with idle-time coroutines)

Collapse
 
miketalbot profile image
Mike Talbot ⭐

I wouldn't have thought so the way it is at the moment as it relies on requestIdleCallback which is a browser thing. Though clearly it could be adapted to work in that environment either by estimating the time per frame (using whatever the RN tick is) or if RN has actually got something to tell us.

I have only dabbled in React Native - would this be useful do you think? Very happy to do a version for it if it would help?

Collapse
 
gollyjer profile image
Jeremy Gollehon

We have a ton of data we must manipulate client side to put in charts. Parallel animations have been a challenge. Something like js-coroutines would potentially provide a much better user experience.

Thread Thread
 
miketalbot profile image
Mike Talbot ⭐

Ok cool - I looked after your comment. It appears that I can do something with the timers. I'm just not sure how much time it will need when reverting to native after the JS. But definitely looks possible. I'm excited to try if you'll find it useful. Will give it a look.

Thread Thread
 
miketalbot profile image
Mike Talbot ⭐ • Edited

Ok, it works :)

js-coroutines 2.1.40 - very recent version of React Native (but I think I've polyfilled requestIdleCallback for older versions)

Demo

Thread Thread
 
gollyjer profile image
Jeremy Gollehon

Sweet! I think I'll be in a place to test this out next week. 👍