Skip to content

Maximum ignores Inline Updates #896

@glrusso

Description

@glrusso

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)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions