fix: remove callback
from callbacks
if Remove()
called
#6916
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What did this pull request do?
ref: #6910 (review)
Modified the
Remove()
method so that it not only sets the removed flag but also removes thecallback
from thecallbacks
withincompile()
.This resolves the following issues:
Get()
method could retrieve callbacks that have already been removed.Remove()
method.In addition, I have made some modifications to the existing tests.
Previously, the specified
before
andafter
for acallback
continued to affect the overall order even after beingRemove()
d. I believe that continuing to have an effect after being removed is an unintended behavior.What do you think? I would appreciate any advice.
User Case Description
The problem where the
Get()
methodIf a callback named
cb1
is registered, it is expected that callingGet("cb1")
afterRemove("cb1")
should returnnil
. However, a callback function registered ascb1
is being returned instead.The problem where the
Remove()
methodThe expectation is that callbacks marked as removed via
Remove()
should not be executed. However, we encountered an issue where callbacks registered through methods likeBefore("*").Register()
continue to operate even after beingRemove()
d.This typically occurs in scenarios such as the following:
workaround
For your reference, using
Before("*").Remove()
can be mentioned as a workaround for the above issue.