DEV Community

Discussion on: Building a Reactive Library from Scratch

Collapse
 
viridia profile image
Talin

Very helpful article. One thing I would like to understand better is the lifecycle of effects, particularly when disposing of effects and signals that are no longer needed - it looks like the cleanup handler never gets called if you never set a signal.

I realize that in this simple example, effects aren't holding on to any resources, so everything would be garbage collected; but I'm having trouble seeing how you would extend this model to one where effects do need to be cleaned up.

My motivation, BTW, is I am working on a 3D game engine where character behavior is driven by a reactive framework that is similar to what you've outlined here. I'm in the process of refactoring it from a React hook style of reactivity to something more like Solid (with some important differences, such as reflection and type introspection).

Collapse
 
ryansolid profile image
Ryan Carniato

Yeah this article doesn't actually get into anything hierarchical, or implement any sort of disposal. In Solid we have an idea of ownership where child effects are owned by parents as well and follow the same disposal pattern. If you want to understand this a bit more I recommend reading the article linked at the end, Reactivity to Rendering. I go into how I built a framework on top of this and it talks more about disposal and ownership.