Skip to content

Maximum ignores Inline Updates #896

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

Open
glrusso opened this issue Apr 18, 2024 · 1 comment
Open

Maximum ignores Inline Updates #896

glrusso opened this issue Apr 18, 2024 · 1 comment
Assignees
Labels

Comments

@glrusso
Copy link

glrusso commented Apr 18, 2024

Code to replicate the issue:

using DynamicData;
using DynamicData.Aggregation;
using DynamicDataRightJoin;

int? max = null;

var cache = new SourceCache<Foo, string>(foo => foo.Id);

var sub = cache
    .Connect()
    .TransformWithInlineUpdate(
        foo => new TransformedFoo(foo.Id)
        {
            TransformedValue = foo.Value
        },
        (transformedFoo, foo) =>
        {
            transformedFoo.TransformedValue = foo.Value;
        })
    .Maximum(transformedFoo => transformedFoo.TransformedValue)
    .Subscribe(newMax =>
    {
        max = newMax;
    });

cache.AddOrUpdate(new Foo("0")
{
    Value = 0
});

Console.WriteLine(max); // 0

cache.AddOrUpdate(new Foo("0")
{
    Value = 1
});

Console.WriteLine(max); // Expected: 1, Actual: 0

sub.Dispose();

If I understood correctly, this is because:

  • TransformWithInlineUpdate calls cache.Refresh(change.Key); when inline updating even if the change reason was Update. Is this intended?
  • ForAggregation ignores changes which reason is Refresh.

Originally posted by @glrusso in #895 (reply in thread)

@JakenVeina
Copy link
Collaborator

I'd say this should be fixed in .ForAggregation() yeah. Refresh is a valid type of change, it should either be supported, or well-documented that it's not supported, and why.

@JakenVeina JakenVeina added the bug label May 29, 2025
@JakenVeina JakenVeina self-assigned this May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants