You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
There is a conversation here 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.
In the meanwhile you can use WeakSubscribe as a workaround. It acomplishes the same thing as ObservableObject with WeekEventManager underneath.
It's marked as Obsolete because XCT already has ObervableObject with WeekEventManager underneath, and if publisher and consumer are both week - subscribtion is removed after 1st GC run. You need to use one or the other, but not both: xamarin/XamarinCommunityToolkit#1001
Using a different way of subscribing as a work around is not really an option, since I may not be in control of the code that is doing the subscribing .
Would it be possible to make ObservableObject.PropertyChanged and ObservableObject.PropertyChanging virtual? That way a consumer could override them to use DelegateWeakEventManager.
I'm currently using
ObservableObject
fromXamarin Community Toolkit
. The implementation is very similar to theObservableObject
here, but one interesting difference is thatPropertyChanged
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 ofObservableObject
here?Xamarin Community Toolkit
has its ownDelegateWeakEventManager
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 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 theIMessenger
) but if it does happen, then it could drop it'sDelegateWeakEventManager
in favour of using one here, if it gets added.dotnet/maui#3880
The text was updated successfully, but these errors were encountered: