Fork me on GitHub

Hey all, Just wanted to share something I’ve been working on recently that essentially lets you use datascript’s d/entity API (well, something similar) in reagent components, only triggering re-renders when the attributes you accessed on each entity change. It’s pretty early on implementation-wise, but I figured that maybe some people here would have experience using reagent and datascript together, so this might be worth sharing now anyway. I apologise in advance for the readme, I just blurted it out in one sitting so it’s a bit stream of consciousness at the moment.

👀 3

I assume this is going to be a bit more efficient than just putting the Datascript DB in a reagent atom?


I did that once, and it was fine for my small DB.


Sorry @U3X7174KS, I’ve only just seen this. Yeah, that’s it. If you put the DataScript DB in a reagent atom then all components that deref that atom will re-render on any DB change. For many apps this works, but for apps that have a lot of UI components, or components that are expensive to render, then it becomes less than ideal. There are other libraries that help solve this same problem, the most well-known is posh ( I’ve used posh a lot and it’s great. This library essentially does the same sort of thing that posh does for d/q & d/pull, but for d/entity.

👍 3