CommunityToolkit / CommunityToolkit/dotnet

More observable collections

Open
#901 0 comments 1 reaction 0 assignees View on GitHub
feature request :mailbox_with_mail:
Dominant language
C#
Stars
3.8k
Forks
400
PR merge metrics
No merged PRs in 30d

Description

### Overview

I am trying to write some observable data classes which use mutable array of a fixed size.
I need something like ObservableCollection 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
{
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.