Skip to content
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

Request to include ObservableRangeCollection, an updated ObservableCollection available as part of Xamarin.CommunityToolkit and MVVM Helpers #256

Closed
egvijayanand opened this issue May 18, 2022 · 13 comments
Labels
api-rejected 🚫 A rejected proposal, PRs will be closed feature request 📬 A request for new changes to improve functionality mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit

Comments

@egvijayanand
Copy link

Overview

Request to include the ObservableRangeCollection, an updated ObservableCollection which raises the notification once rather than raising it for every item and it will not be part of the CommunityToolkit.Maui as this MVVM Toolkit is the recommended way to move forward for all MVVM-based applications.

And this type provides a multitude of methods to work on a range of items.

API breakdown

https://github.com/xamarin/XamarinCommunityToolkit/blob/main/src/CommunityToolkit/Xamarin.CommunityToolkit/ObjectModel/ObservableRangeCollection.shared.cs

Usage example

var items = new ObservableRangeCollection<string>();
items.AddRange(new[] { "First", "Second", "Third", "Fourth" });
items.RemoveRange(new[] { "First", "Second" });
items.ReplaceRange(new[] { "iOS", "Android", "macOS", "Tizen", "Windows" });

Breaking change?

No

Alternatives

As of now copy and paste the code into all available projects.

Additional context

This is pretty useful for lazy loading such as the Pagination of a collection.

Query the items from the remote API via network calls or from the local databases such as SQLite.

Help us help you

No, just wanted to propose this

@egvijayanand egvijayanand added the feature request 📬 A request for new changes to improve functionality label May 18, 2022
@Sergio0694 Sergio0694 added the mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit label May 27, 2022
@Sergio0694
Copy link
Member

This has been proposed already, but is not planned. We're trying to just push for .NET 7 to add support for this built-in 🙂
See dotnet/runtime#18087.

@Sergio0694 Sergio0694 closed this as not planned Won't fix, can't repro, duplicate, stale May 27, 2022
@Sergio0694 Sergio0694 added the api-rejected 🚫 A rejected proposal, PRs will be closed label May 27, 2022
@tranb3r
Copy link

tranb3r commented May 9, 2023

Hi,
One year later, it does not seem like this request has made any real progress in dotnet runtime.
Meanwhile, our maui apps still have to depend on 3rd party libs like MVVM Helpers, even when using CommunityToolkit.MVVM, which is a bit of a nonsense.

@Sergio0694
Could you please reconsider this proposition to include in CommunityToolkit.MVVM the ObservableRangeCollection?
Thanks

@egvijayanand
Copy link
Author

IMO, this should've made it to the v8.2.0 of the toolkit. Unfortunately, this issue stands closed. @Sergio0694 kindly consider reopening this to make the toolkit even more usable.

@tranb3r
Copy link

tranb3r commented Jul 5, 2023

@Sergio0694 Sorry to ask again... is your answer a definite no?

@Sergio0694
Copy link
Member

That's correct, this is not something we'll add 🙂
It's already tracked in the runtime repo (for adding this to the BCL), and besides, adding such a type to the MVVM Toolkit would face the same issues anyway: it'd be completely unusable on most common UI frameworks as of today (WPF, UWP, WinUI 3, MAUI, at the very least).

@tranb3r
Copy link

tranb3r commented Jul 5, 2023

But, so far I'm using MvvmHelpers's implementation, and it seems perfectly fine... unless there is something I'm not understanding.
So, could you please summarize here the reason why you think it'd be completely unusable in MAUI?
I'm not sure I want to read several hundreds of comments from the dotnet/runtime issue...

@egvijayanand
Copy link
Author

egvijayanand commented Jul 5, 2023

That's correct, this is not something we'll ad

There's a lot of traction on this feature and .NET 8 being an LTS release, many would prefer to migrate to this release.

Since hardly there's little time left, maybe two more public previews, before the API freeze in an RC release.

So kindly highlight it to the runtime team on the need to implement this at the earliest.

Thanks in advance.

@Sergio0694
Copy link
Member

"could you please summarize here the reason why you think it'd be completely unusable in MAUI?"

@tranb3r I've added more context in dotnet/runtime#18087 (comment) and following comments, you can just read from there and not go through the entire discussion. TLDR: it's complicated and will cause problems on some frameworks 😅

"So kindly highlight it to the runtime team on the need to implement this at the earliest."

They're aware of the request, but as we mentioned in that discussion, this is a particularly tricky problem. I am not optimistic this will make it in .NET 8 at all. In fact at this point I'm relatively confident it'll miss this release, unfortunately.

@tranb3r
Copy link

tranb3r commented Jul 5, 2023

Ok, so I understand it's too complicated to implement it in the BCL.
However, isn't it the purpose of CommunityToolkits to fill the gap and implement features that people need, without waiting for major releases of dotnet?
Maybe this could be part of CommunityToolkit.Maui? (or is there any incompatibility with Maui?)

@Sergio0694
Copy link
Member

"Ok, so I understand it's too complicated to implement it in the BCL."

No it's actually the other way around 😅
Implementing this in the BCL is very easy. The issue is that it wouldn't work in many of these UI frameworks. Which as I mentioned, is also why adding this API somewhere else (eg. in the MVVM Toolkit) wouldn't help. If you tried to then use it eg. in a UWP or WinUI 3, or WPF app, it wouldn't work, so you'd just be back at square 1, just with extra steps.

@tranb3r
Copy link

tranb3r commented Jul 6, 2023

So, again, maybe this could be added to CommunityToolkit.Maui?
At least Maui apps would benefit from it immediately.

They rejected it because they thought it would be implemented in dotnet or CommunityToolkit.Mvvm.
But maybe they could reconsider the proposal, now that it's clear it's not going to be part of dotnet or CommunityToolkit.Mvvm soon.
CommunityToolkit/Maui#99 (comment)

cc @brminnick
What do you think?

@Sergio0694
Copy link
Member

Adding this to the MAUI toolkit would have the same exact issues. It might work in some scenarios, but eg. if you're running your MAUI app on Windows, which would use WinUI 3 as backend, then that'd have the same problem we already mentioned, and it wouldn't work. Same if MAUI happened to get a WPF backend, that'd also not work with this, for instance.

@tranb3r
Copy link

tranb3r commented Jul 6, 2023

OK. Thank you for the clarifications!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-rejected 🚫 A rejected proposal, PRs will be closed feature request 📬 A request for new changes to improve functionality mvvm-toolkit 🧰 Issues/PRs for the MVVM Toolkit
Projects
None yet
Development

No branches or pull requests

3 participants