-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Reassigning variable used as action should be reactive and destroy old action #6754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
There are several things going on here, but one of them is that you are setting the action to |
@Conduitry Ok, sorry, I corrected it. Changing action to
I would like
|
I think what OP tries to explain is that the action should "remount" when it's invalidated, which I think is a fair assumption. Though I never really had the need for something like this, usually I'd have an |
In other words: when using
Same, but it's a pain because actions already give you a lot of responsibility (e.g. manually unbinding events) and keeping things consistent when not only the options can change but you can also disable the entire thing is hard. I always wished there was a way to remove an action, but swapping out the entire thing is not what I had in mind. |
I was thinking about the possibility of setting This is how it works in Svelte, with the normal properties of HTML elements. But I was also thinking about a general way to turn off atypical element properties in Svelte (for use:action bind:value, on:click etc.). A loose idea, e.g. That would be a new, unusual syntax, next to the proposition |
Closing in favor of #6942 |
Describe the bug
When I change a function in
use:action
to something else, destroy neither executes nor adds the other action.Putting an item in
#key
helps.Actually, I'd like to be able to replace a function in
use:action
without a#key
, because#key
is a more drastic solution than simply executingdestroy
and adding a new action.Reproduction
Described example:
https://svelte.dev/repl/730c59ca84e8486aa67108a0d4544bbc?version=3.42.6
Click "remove action" in First case - does nothing and should execute
destroy
.Click "remove action" in Second case - When you use
#key
,destroy
is executed.Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: