CommunityToolkit / Maui

The .NET MAUI Community Toolkit is a community-created library that contains .NET MAUI Extensions, Advanced UI/UX Controls, and Behaviors to help make your life as a .NET MAUI developer easier
https://learn.microsoft.com/dotnet/communitytoolkit/maui
MIT License
2.21k stars 380 forks source link

[Proposal] ObservableRangeCollection #99

Closed brminnick closed 2 years ago

brminnick commented 2 years ago

ObservableRangeCollection

Summary

Represents a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed

Detailed Design

public class ObservableRangeCollection<T> : ObservableCollection<T>
{
  public ObservableRangeCollection() : base()
  {
  }

  public ObservableRangeCollection(IEnumerable<T> collection) : base(collection)
  {
  }

  public void AddRange(IEnumerable<T> collection, NotifyCollectionChangedAction notificationMode = NotifyCollectionChangedAction.Add);

  public void RemoveRange(IEnumerable<T> collection, NotifyCollectionChangedAction notificationMode = NotifyCollectionChangedAction.Reset);

  public void Replace(T item);

  public void ReplaceRange(IEnumerable<T> collection);
}

Usage Syntax

XAML Usage

N/A

C# Usage

public ObservableRangeCollection<int> collection = new();

public void AddNumbers(int count)
{
  var startingNumber = collection.Length;
  collection.AddRange(Enumerable.Range(startingNumber, count));
}

Drawbacks

We are deferring all MVVM components to the MVVM Toolkit, keeping the .NET MAUI Community Toolkit focused on .NET MAUI-specific tools.

Alternatives

brminnick commented 2 years ago

Recommend adding this to the MVVM Toolkit: https://docs.microsoft.com/en-us/windows/communitytoolkit/mvvm/introduction

angelru commented 2 years ago

do you know when it will be?

bijington commented 2 years ago

I wonder is this a good candidate for the dotnet toolkit?

https://github.com/CommunityToolkit/dotnet

@brminnick what do you think?

brminnick commented 2 years ago

Agreed.

There are efforts being made internally to still sneak it into .NET 7.

But if it were to be added to a Community Toolkit, then https://github.com/CommunityToolkit/dotnet would be the best toolkit for it.

maxkoshevoi commented 2 years ago

@brminnick Have it make it to .NET 7? (since it's in RC now)

kkppstudios commented 1 year ago

Looks like it's marked for .NET 8. Is this correct? https://github.com/dotnet/runtime/issues/18087

Any suggestions?

pictos commented 1 year ago

@kkppstudios you can copy the implementation to your code and use it there

BillyMartin1964 commented 7 months ago

ObservableRangeCollection doesn't seem to be in .net 8 either. When will it be done?

bijington commented 7 months ago

ObservableRangeCollection doesn't seem to be in .net 8 either. When will it be done?

That's outside of your hands. I did read that it's being evaluated for .NET 9. For now you can bring in one of the documented options in the Alternatives section if you need it

chrisc-ona commented 3 weeks ago

It appears it has now slipped to .NET 10 at the earliest per https://github.com/dotnet/runtime/issues/18087#issuecomment-2266244088