@cmdrdats The pattern you describe is known (part of optimization of a component) and the issue you describe is also known as @roman01la said above.
Personally I use a hook that does the cleanup
Something along the lines: https://github.com/g7s/rum/blob/hooks/src/rum/core.cljs#L572
@g7s great, thanks for the feedback - use-derived-atom
looks interesting - is this in a fork?
Yes it is in a fork that I had made long ago.
ah, ok - I see the current rum code has:
(defn use-reducer [reducer-fn initial-value]
[initial-value reducer-fn])
(defn use-effect!
([setup-fn])
([setup-fn deps]))
(defn use-callback
([callback] callback)
([callback deps] callback))
probably in prep for moving away from React?
I guess a similar effect might be achieved with a mixin if there's a registry of derived atoms against a component?
Yeah exactly you can do that with a mixin as you describe