dotnet icon indicating copy to clipboard operation
dotnet copied to clipboard

More observable collections

Open Shadowblitz16 opened this issue 1 year ago • 0 comments

Overview

I am trying to write some observable data classes which use mutable array of a fixed size. I need something like ObservableCollection<T> but without the ability to add and remove items.

I also noticed that there are no equivalents of Dictionary, Stack, Queue, and HashSet which would be nice.

API breakdown

Observable Arrays would be ObservableCollection without any methods that add or remove items. Items could still be mutated and they would trigger collection.property changes

I don't know about the other collections, I'm sure they would just use the same api as the normal system.collections do they would just support notification.

Usage example

public sealed class ColorMap : ObservableArray<ObservableColor>
{
    public ColorMap(uint colorCount, uint shadeCount=1) : base(colorCount * shadeCount)
    {
        
    }
}

Breaking change?

I'm not sure

Alternatives

For array exposing the ability to add and remove items, for things like dictionary probably nothing.

Additional context

Right now I am trying to make a indexed image system using notifications. When the color in the palette or image changes I reflect that on the actual bitmap.

Help us help you

No, just wanted to propose this

Shadowblitz16 avatar Jul 08 '24 23:07 Shadowblitz16