Skip to content

fix: send modification notification from AutoMap.Add() with existing key - #19

Merged
wlsnmrk merged 2 commits into
chickensoft-games:mainfrom
wlsnmrk:fix/map-add-notify-modified-if-update
Jul 1, 2026
Merged

fix: send modification notification from AutoMap.Add() with existing key#19
wlsnmrk merged 2 commits into
chickensoft-games:mainfrom
wlsnmrk:fix/map-add-notify-modified-if-update

Conversation

@wlsnmrk

@wlsnmrk wlsnmrk commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Same basic bug and fix as #18, but sort of in reverse. Using AutoMap.Add() to update an existing key will now invoke callbacks registered via OnModify():

var myAutoMap = new AutoMap<int, int>();
myAutoMap.Add(0, 0);
myAutoMap.OnModify(() => Print("myAutoMap modified!"));
// will now print "myAutoMap modified!"
myAutoMap.Add(0, 1);

This behavior was failing previously.

Also added tests to verify that both OnUpdate() and OnModify() callbacks are invoked when an existing key-value pair is updated via Add().

wlsnmrk added 2 commits July 1, 2026 03:29
Added tests for the update behavior of the Add() method.

Note: One new test failing.
Fixed failing test for AutoMap.Add() by broadcasting a modification
notification when an add op is actually an update op for an existing
value.
@wlsnmrk
wlsnmrk merged commit aa201a4 into chickensoft-games:main Jul 1, 2026
2 checks passed
@wlsnmrk
wlsnmrk deleted the fix/map-add-notify-modified-if-update branch July 1, 2026 07:39
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.

1 participant