WeakSubscriber.Create<TOwner, TEventArgs, THandler>(TOwner, Action<TOwner, Object, TEventArgs>, Action<IWeakSubscriber<THandler>, Object>, Func<WeakSubscriber.IHandler<TEventArgs>, THandler>) Method
In This Article
Creates an event handler that prevents memory leaks caused by strong references between event publishers and subscribers.
Namespace: DevExpress.Maui.Mvvm
Assembly: DevExpress.Maui.Mvvm.dll
NuGet Package: DevExpress.Maui.Mvvm
#Declaration
C#
public static IWeakSubscriber<THandler> Create<TOwner, TEventArgs, THandler>(
TOwner eventHandlerOwner,
Action<TOwner, object, TEventArgs> eventHandler,
Action<IWeakSubscriber<THandler>, object> unsubscribe,
Func<WeakSubscriber.IHandler<TEventArgs>, THandler> createHandler
)
where TOwner : class
#Parameters
Name | Type | Description |
---|---|---|
event |
TOwner | The class instance that handles the specified event. |
event |
Action<TOwner, System. |
An action that invokes when the event occurs. |
unsubscribe | Action<IWeak |
An action that unsubscribes from the specified event. |
create |
Func<Weak |
The function that returns the actual event handler. It is always should be: |
#Type Parameters
Name | Description |
---|---|
TOwner | The type of class that handles an event. |
TEvent |
The type of event arguments associated with the event. |
THandler | The event handler type. |
#Returns
Type | Description |
---|---|
IWeak |
An object that provides the event handler to make an event subscription. |
See Also