refactor: Make GestureDetectorBuilder and detector/callback registering more resilient#3900
refactor: Make GestureDetectorBuilder and detector/callback registering more resilient#3900luanpotter wants to merge 2 commits intomainfrom
Conversation
26b9a08 to
f46ad2e
Compare
f46ad2e to
0e0ab5a
Compare
| /// | ||
| /// 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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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)
Description
Make GestureDetectorBuilder and detector/callback registering more resilient wrt to multiple registrations (callbacks that use the same detector).
Checklist
docsand added dartdoc comments with///.examplesordocs.Breaking Change?