Open expipiplus1 opened 4 years ago
This is definitely something that would be nice to have. Reflex's built-in resource management is all GC-driven, so it's only appropriate for situations where prompt destruction is not required. However, we do have a system that can be leveraged for this: Adjustable. In reflex-dom, when widgets are removed from the DOM, it happens, of course, promptly. We also use this in QueryT to promptly unsubscribe from queries that we're no longer interested in.
My basic idea for this would be that a "disposable" widget provides a "disposal" routine to its parent, inside of a Behavior or a Dynamic. When the widget is removed by Adjustable, the disposal routine will be invoked. Do you think that would cover your use case?
A dynamic destructor sounds very useful, yeah. What would the story be regarding exception safety for these widgets?
On Tue, May 19, 2020, 2:12 AM Ryan Trinkle notifications@github.com wrote:
This is definitely something that would be nice to have. Reflex's built-in resource management is all GC-driven, so it's only appropriate for situations where prompt destruction is not required. However, we do have a system that can be leveraged for this: Adjustable. In reflex-dom, when widgets are removed from the DOM, it happens, of course, promptly. We also use this in QueryT to promptly unsubscribe from queries that we're no longer interested in.
My basic idea for this would be that a "disposable" widget provides a "disposal" routine to its parent, inside of a Behavior or a Dynamic. When the widget is removed by Adjustable, the disposal routine will be invoked. Do you think that would cover your use case?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/reflex-frp/reflex/issues/428#issuecomment-630350955, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGRJXACSJYNZZBW5BFZPNTRSF3ANANCNFSM4NDZQRLQ .
I think this is at least an issue with documentation.
It's not clear from reading the examples or the manual how a reflex-frp program might deal with scarce resources, i.e. resources which must be freed promptly (not left up to a finalizer). I'd like to think that FRP would be a good fit for managing complex object lifetimes (particularly object creation when needed). On the other hand from https://github.com/reflex-frp/reflex-dom/issues/114 it looks as guaranteed destruction might be problematic with reflex.
Either way I think it might be good to at least have a footnote or something somewhere with some greppable terms related to resource management.