Using an entity component system for an
Using an entity component system for an application I'm working on and did something really fun with convex recently. I was able to generate unique jotai atoms for each instance of a component by entity key derived from Convex generated types. So like.. I don't have to create a dedicated atom for each component and convex really is my source of truth now. Pretty nice. (code in thread for reference)
5 Replies
Really niche use case, but I think the lightbulb in my head went off on how awesome convex is once I figured this out. Hard to overstate how much boilerplate this has saved me
On the convex side, I can update component data with something like:
Which is nice since I have hundreds of tables representing various components and the producer of the data can't be opinionated on how that data is consumed.
don't mind me, over here getting excited over a simple factory pattern 🙃
I love ECS
such an elegant design for something like an actor system/game system etc
We’re building a CAD tool for drug discovery. A lot of the principles of game development actually apply pretty well to CAD tools haha
Jotai is a great companion for Convex. I've dreamed of building a full integration, looks like you're on the way there. I find that ECS is usually discussed in terms of performance, but I find the organisational pattern so useful, and it maps pretty well to the web, React, the flux pattern, etc.
Oh 1000%! Convex and jotai fit like a glove, I was pleasantly surprised. Once I have everything together I'll probably write a devblog about it.
In applications where the consumer of the data is more opinionated than the producer of the data (think: games, whiteboarding tools, CAD, even big data ETL pipelines) ECS is a phenomenal pattern. I think most people have object oriented design hammered into their heads in university so it's a bit counter intuitive when you first start using it, but it's a fantastic tool in the toolbelt when you find your data models getting extremely brittle / bloated