Skip to content

Callback registry grows unboundedly, old callbacks never removed #202

@jappeace-sloth

Description

@jappeace-sloth

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions