devfd/react-native-workers

Simple example?

DarrylD opened this issue · 5 comments

Trying to picture using this but, not sure where the "worker" lives. For example, how would I poll an endpoint in the work and send that data to the app?

devfd commented

the worker run on a separate thread so you can execute heavy tasks without blocking the UI thread. (same as when you run a web worker on your web app)

after polling your endpoint, you use self.postMessage to send the data to your main thread (ui thread).

the lib will be updated shortly to be used with RN 0.30. stay tune

Really excited about this. My react-native app is so janky during non-trivial computations. I'd love to move everything over to another thread.

+1 for creating a complete (albeit simple) example with instructions on how to build and run it. I know there isn't any automatic packaging, but if everything loads from the index.[ios|android].js file I'm not sure how to use this?

devfd commented

@seantempesta out of curiosity what kind of computations are your running on your app ?

a simple sample app is on the way

I'm developing a clojurescript app using a client side database called datascript (https://github.com/tonsky/datascript). The database has participants belonging to different groups, and attendance can be recorded. Computations are generally ad hoc (from incoming events) or by time (groups have start and end times). This leads to 2-3 second delays just to display the current state of a given group->participant set.

But, since I'm using re-frame (https://github.com/Day8/re-frame) all of these computations live in a separate boundary and the results are transfered via a message-like system. So being able to offload the entire database and resulting computations sounds like a huge win for me.

@devfd at the moment just listening to a socket and populating my redux store.