Skip to content

Conversation

@ealmloff
Copy link
Member

@ealmloff ealmloff commented Nov 11, 2025

Inserting into a hashmap or btreemap currently only marks the hashmap itself as dirty which will cause any get or iter operations to rerun, but it doesn't mark the existing value at the entry as dirty. This PR fixes that issue.

Fixes #4956

@ealmloff ealmloff requested a review from a team as a code owner November 11, 2025 17:55
@ealmloff ealmloff added bug Something isn't working stores labels Nov 11, 2025
@jkelleyrtp
Copy link
Member

Re: the comment on the changed bit, we do have the Ord bound which implies Eq + PartialEq - is there no way to use those to determine if it can be marked dirty?

@ealmloff
Copy link
Member Author

ealmloff commented Nov 11, 2025

Re: the comment on the changed bit, we do have the Ord bound which implies Eq + PartialEq - is there no way to use those to determine if it can be marked dirty?

Not that I can think of. Store selectors need to be stable over time and copy. Currently they are [u32; LEN] where each entry is either a list index or a hash of the type. The other index I could think of for BTrees is the order in the tree, but that is not stable over time if you insert an element before the element you are holding. For example, that would break this case:

let tree = store_hashmap();
// Creates path [0]
tree.insert(1, String::new());
// Holds path [0] in the selector subscription tree
let first = tree.get(1);
// Creates path [0] and shift the original value to the second item
tree.insert(0, "wrong value".to_string());
// This now references (the subscriptions for) "wrong value"
first.read();

@jkelleyrtp jkelleyrtp merged commit bd2d1de into DioxusLabs:main Nov 13, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working stores

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WritableHashMapExt::insert doesn't trigger rerender when overwriting an item.

2 participants