What's the best simple way to handle the update pattern?

This is off topic i guess, but maybe it helps you to avoid the same kind of issues that we faced.

At work we’re making a CAD system based on threejs, also a head-less framework for modelling operations similar to three-csg, but at full CAD capacity. Updates were exactly like the method described above. When consumed it was put into a collection to avoid full traverse.

Eventually it became clear that the pattern caused problems. Objects updating themselves turned out to be a recipe for race conditions. The object should be a reflection of state, it shouldn’t bear implicit knowledge of state. Whenever render order changed for whatever reason (server push, etc), it became mind boggling, behaviour was basically switching around in no manageable order.

After years of fighting against it we figured that updates belong to the component level. By that i mean the instance that has access to state or logic as well as the view. That layer receives state and acts upon view objects, also frame based if needed. This is a very prominent pattern in front-end these days, and i think even gaming would benefit from that.

2 Likes