Skip to content
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

feat(reactive_stores): add map_untracked to OptionStoreExt #3245

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

tqwewe
Copy link
Contributor

@tqwewe tqwewe commented Nov 15, 2024

Adds an unreactive variant of OptionStoreExt::map called map_untracked.

I didn't add any tests for this, as I'm not entirely sure what to test for.


On another note, the docs for OptionStoreExt::map state:

will cause it to re-run if the field toggles betwen None and Some(_).

Is this implying it will only be reactive if it changes from None to Some, and will not react to Some(a) -> Some(b) updates to the field? I may be wrong, but from my experience, it seems like it will react regardless if it directly changes between Some and None, and will indeed react to any changes to the field.

@tqwewe tqwewe force-pushed the feat/reactive-stores-map-untracked branch from a308a90 to 194afd4 Compare November 15, 2024 07:19
@gbj
Copy link
Collaborator

gbj commented Nov 18, 2024

Thanks, this looks good. I'm pretty sure that the inaccurate doc there (which implies that Some => Some won't notify) was written earlier on, before I'd figured out how parent/child notification relationships really need to work...

But in fact it seems to me that the behavior that the documentation describes is actually the desired behavior, right? i.e., the map() function here probably should memoize on Some-ness, because if it's Some -> Some the user will catch the change anyway because they're planning to track the subfield?

@gbj gbj merged commit 0258ac6 into leptos-rs:main Nov 18, 2024
74 checks passed
@tqwewe
Copy link
Contributor Author

tqwewe commented Nov 18, 2024

But in fact it seems to me that the behavior that the documentation describes is actually the desired behavior, right?

I've scratched my head for a while, but don't have a good answer for this really. Only thing I'm wondering is, if it did memoize on Some-ness, then what if you wanted to get reactive changes on inner field updates (like what it does currently)? Might be a problem in that case

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