Problem
ActionState in src/Hatter/Action.hs holds two IntMaps for click and text-change callbacks. These maps only grow — the asNextId counter increments monotonically and old entries are never removed.
The intended usage is to create all callbacks once at init time via ActionM, but nothing enforces this — users can call runActionM inside their view function, creating fresh handles every render cycle. The docs discourage it but the types don't prevent it.
Impact
Low priority. In the typical usage pattern (callbacks created once at init), no leak occurs. Only affects apps that create callbacks dynamically during rendering.
Approach
Expose a cleanup API so users who create callbacks dynamically can manage their own lifecycle. Something like:
destroyAction :: Action -> ActionM () — remove a click callback by handle
destroyOnChange :: OnChange -> ActionM () — remove a text-change callback by handle
We don't want to prevent dynamic callback creation — we don't know what weird stuff users are building. Just give them the tools to clean up after themselves.
Problem
ActionStateinsrc/Hatter/Action.hsholds twoIntMaps for click and text-change callbacks. These maps only grow — theasNextIdcounter increments monotonically and old entries are never removed.The intended usage is to create all callbacks once at init time via
ActionM, but nothing enforces this — users can callrunActionMinside their view function, creating fresh handles every render cycle. The docs discourage it but the types don't prevent it.Impact
Low priority. In the typical usage pattern (callbacks created once at init), no leak occurs. Only affects apps that create callbacks dynamically during rendering.
Approach
Expose a cleanup API so users who create callbacks dynamically can manage their own lifecycle. Something like:
destroyAction :: Action -> ActionM ()— remove a click callback by handledestroyOnChange :: OnChange -> ActionM ()— remove a text-change callback by handleWe don't want to prevent dynamic callback creation — we don't know what weird stuff users are building. Just give them the tools to clean up after themselves.