Fork me on GitHub
#datascript
<
2021-04-03
>
raspasov11:04:10

@lilactown yeah, React Native gets a bit of a pass with the separate JS thread which runs the JS logic in the sense that you can start, say, a native loading animation on the main UI thread, and wait for the JS thread to finish its slow work; that way the user experience should be relatively smooth. The native UI thread loading animation won’t be blocked by the JS thread. You’re still blocked from doing any JS logic work for that period, unfortunately. Offloading DataScript to a worker would fix that (same applies to browser JS, I think)

raspasov11:04:29

One trick I’ve employed with long lists of data coming out of Datascript is to query the data like this (using the index directly):

(reverse
  (d/datoms db :avet :exercise-set/end-time))
You get a list of DataScript eids like [1243 1240 1237 1234 1231 1228 1215 1212 1209 1206 …] I use the vector of eids to render a list of components and each row component in the list fetches the relevant entity only when it becomes visible on the screen (this is all using the React Native’s VirtualizedList but I believe there’s similar libs for browser JavaScript to handle long lists of data).

3
raspasov11:04:17

Using this trick, I am able to render hundreds (and I think thousands should be no problem) of items lazily without any skipped frames;