WindowsCommunityToolkit icon indicating copy to clipboard operation
WindowsCommunityToolkit copied to clipboard

WeakEventListener in NetworkConnectionStateTrigger is duplicated

Open michael-hawker opened this issue 3 years ago • 1 comments

Describe the bug

Looks like NetworkConnectionStateTrigger is using a private copy of WeakEventListener, it's identical to the one we already have in the Toolkit, so we should update the source to use the existing code within the Toolkit.

https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/ebb12e0c38c22ec01849e202f8e477d8c1a67061/Microsoft.Toolkit.Uwp.UI/Triggers/NetworkConnectionStateTrigger.cs#L73

Expected behavior

Use existing code over shadow copy.

https://github.com/windows-toolkit/WindowsCommunityToolkit/blob/ebb12e0c38c22ec01849e202f8e477d8c1a67061/Microsoft.Toolkit.Uwp/Helpers/WeakEventListener.cs#L17

michael-hawker avatar Jun 01 '21 20:06 michael-hawker

While closing #4450, we noticed that the code is not identical to what we have in the toolkit. It removes TEventArgs to allow us to do NetworkInformation.NetworkStatusChanged += weakEvent.OnEvent;.

After discussing with @michael-hawker, we won't be removing the private event listener for now. Instead, we'll use the more flexible https://github.com/CommunityToolkit/dotnet/issues/404 when it arrives.

Arlodotexe avatar Sep 15 '22 20:09 Arlodotexe