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
{{ message }}
This repository has been archived by the owner on May 1, 2024. It is now read-only.
With XF 5.0 the WeakEventManager has been made public. I highly laud this development, as this is a step in the right direction to expire my custom implementation. However, in all cases where I'm using my own WeakEventManager, I'm using events with handlers that pass object-values rather than EventArgs. The constraint where TEventArgs: EventArgs in Forms' implementation of the WeakEventManager therefore requires me encapsulate the values I wish to pass in an EventArgs-object. It would be great if this would not be necessary.
API Changes
Either A) change the following signatures
public void AddEventHandler<TEventArgs>(EventHandler<TEventArgs> handler, [CallerMemberName] string eventName = null) where TEventArgs : EventArgs;
public void RemoveEventHandler<TEventArgs>(EventHandler<TEventArgs> handler, [CallerMemberName] string eventName = null) where TEventArgs : EventArgs;
into
public void AddEventHandler<TEventArgs>(EventHandler<TEventArgs> handler, [CallerMemberName] string eventName = null);
public void RemoveEventHandler<TEventArgs>(EventHandler<TEventArgs> handler, [CallerMemberName] string eventName = null);
or B) add overrides to the extent of the above.
Intended Use Case
The default language implementation of EventHandler<TEventArgs> doesn't place any constraints on the object-type
for TEventArgs. Therefore, events may be created that do not pass EventArgs-type objects. Such events can now not be used in combination with the WeakEventManager and thus still require custom implementations - especially when event signatures cannot be changed, e.g. when consuming a dependency-library.
The text was updated successfully, but these errors were encountered:
Thanks for this suggestion! As Xamarin.Forms is now in maintenance mode, this will not happen anymore for Xamarin.Forms. We're only adding bugfixes and stability fixes.
If this is still important to you, make sure to check the .NET MAUI repo and see if it's already on the roadmap. If not, feel free to open a discussion to discuss a change first or open an issue with a detailed feature request. Thanks!
Summary
With XF 5.0 the
WeakEventManager
has been made public. I highly laud this development, as this is a step in the right direction to expire my custom implementation. However, in all cases where I'm using my ownWeakEventManager
, I'm using events with handlers that pass object-values rather thanEventArgs
. The constraintwhere TEventArgs: EventArgs
in Forms' implementation of theWeakEventManager
therefore requires me encapsulate the values I wish to pass in anEventArgs
-object. It would be great if this would not be necessary.API Changes
Either A) change the following signatures
into
or B) add overrides to the extent of the above.
Intended Use Case
The default language implementation of
EventHandler<TEventArgs>
doesn't place any constraints on the object-typefor
TEventArgs
. Therefore, events may be created that do not passEventArgs
-type objects. Such events can now not be used in combination with theWeakEventManager
and thus still require custom implementations - especially when event signatures cannot be changed, e.g. when consuming a dependency-library.The text was updated successfully, but these errors were encountered: