Skip to content

refactor: Make GestureDetectorBuilder and detector/callback registering more resilient#3900

Draft
luanpotter wants to merge 2 commits intomainfrom
luan.recognizers
Draft

refactor: Make GestureDetectorBuilder and detector/callback registering more resilient#3900
luanpotter wants to merge 2 commits intomainfrom
luan.recognizers

Conversation

@luanpotter
Copy link
Copy Markdown
Member

Description

Make GestureDetectorBuilder and detector/callback registering more resilient wrt to multiple registrations (callbacks that use the same detector).

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

@luanpotter luanpotter force-pushed the luan.recognizers branch 2 times, most recently from 26b9a08 to f46ad2e Compare April 19, 2026 15:58
///
/// If no component is registered under [key], creates one via [create],
/// registers it under [key], and adds it to the game.
void addDispatcher(ComponentKey key, Component Function() create) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, it was kind of nice to not have the dispatchers have special treatment, that they were just part of the component tree like any other component. How come we can't do this while mounting the dispatcher instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that would be too late, we need to prevent adding it if it exists. (the key registering part could be on mount but then if we have this might as well leave it together for consistency)
this logic was already there, just duplicated on every single dispatcher
I am not 100% happy with it living on the game though, I was considering making a "BaseDispatcher" (though this would have to be a static function, so it is weird)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this PR is a draft btw :P I was still mulling over (I was waiting for the test changes so I could see what was breaking and turns out, nothing)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants