CommunityToolkit / CommunityToolkit/dotnet

Weak PropertyChanged on ObservableObject

Open
#80 3 comments 4 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
3.8k
Forks
400
PR merge metrics
No merged PRs in 30d

Description

I'm currently using `ObservableObject` from `Xamarin Community Toolkit`. The implementation is very similar to the `ObservableObject` here, but one interesting difference is that `PropertyChanged` event is implemented using a weak event manager implementation.

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

Is there any possibility of bringing a weak `PropertyChanged` version of `ObservableObject` here?

`Xamarin Community Toolkit` has its own `DelegateWeakEventManager` which would also need implementing.

https://github.com/xamarin/XamarinCommunityToolkit/blob/main/src/CommunityToolkit/Xamarin.CommunityToolkit/Helpers/DelegateWeakEventManager.shared.cs

There is a conversation [here](https://github.com/dotnet/runtime/issues/61517) about bringing such a class directly into the BCL, but I would guess it would be quicker and easier to add it here (even if it becomes obsolete in the future).

As another aside, on the MAUI front, `DelegateWeakEventManager` has been promoted to the main MAUI repo. There is a discussion going on there about the possibility of depending on .NET Community Toolkit (for the main purpose of using the `IMessenger`) but if it does happen, then it could drop it's `DelegateWeakEventManager` in favour of using one here, if it gets added.

https://github.com/dotnet/maui/pull/3880

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.