-
-
Notifications
You must be signed in to change notification settings - Fork 707
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
Replace try_get()
with get()
in several trait implementations for signals
#3569
base: main
Are you sure you want to change the base?
Replace try_get()
with get()
in several trait implementations for signals
#3569
Conversation
…arena` macro) to prevent panicking if the signal was disposed
… macro) to prevent panicking if the signal was disposed
…if the signal was disposed
…if the signal was disposed
…or signals to prevent panicking if the signal was disposed
…Effect::new_with_value`
…king if the signal was disposed
Copied from the other one you've opened, so apologies if you read that one first. Feel free to reply to either one Overall I think using .try_get() is a decent solution here for panic prevention, but I am worried that instead of getting a panic it seems like this implementation just eats the error. I imagine it would have to emit an error somewhere user visible, whether that's the console in the browser or the server log on the server when the Signal is disposed. I'm not sure returning the previous value is a good choice there either |
Sorry for the duplicated commit history. I wrote (#3582) based on the changes here. Although this PR includes some newer commits not present in the later PR. Generally, I think if you merge this one first and then the later one, commits with the same hashes will be unified. Most of the time, disposed signals occur when a reactive item is deleted. (For example, deleting an |
Yeah, that sounds reasonable to me |
I added a macro called I'm unsure about:
I've pushed the changes for now to get some help here. In |
This PR replaces the use of
get()
withtry_get()
for retrieving signal values in these trait implementations:IntoProperty
IntoClass
IntoStyle
Render
RenderHtml
AttributeValue
InnerHtmlValue
This change prevents potential panics when the signal is disposed.
As a result, I've replaced most
if let
blocks inRenderEffect
s withmatch
statements to handle different variations of the previous state and the signal value better.There are some match arms that don't make much sense to me, which usually happens when a signal is disposed, so I just returned
None
or the previous state if it was possible.