Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Enhancement] Allow everyone access to the WeakEventManager class #8405

Closed
rwaldenfraedom opened this issue Nov 6, 2019 · 5 comments · Fixed by #12063
Closed

[Enhancement] Allow everyone access to the WeakEventManager class #8405

rwaldenfraedom opened this issue Nov 6, 2019 · 5 comments · Fixed by #12063
Labels
in-progress This issue has an associated pull request that may resolve it! proposal-open t/enhancement ➕

Comments

@rwaldenfraedom
Copy link

Summary

I would like to use the WeakEventManager so that my event registrations don't hold on to object when they should have been removed.

API Changes

change the class viability modifier from internal to public on the class Xamarin.Forms.WeakEventManager

e.g.

internal class Xamarin.Forms.WeakEventManager

to

public class Xamarin.Forms.WeakEventManager

Intended Use Case

Allow object to be disposed if the only thing that still references then are event registrations

@brminnick
Copy link
Contributor

brminnick commented Nov 6, 2019

@rwaldenfraedom I’ve implemented WeakEventManager in this library: https://github.com/brminnick/AsyncAwaitBestPractices#weakeventmanager

It is available in NuGet here: https://www.nuget.org/packages/AsyncAwaitBestPractices/

This was inspired by Xamarin.Forms’ WeakEventManager, and I’ve expanded on it, adding support for event Action, event Action<T>, and event Delegate.

@rwaldenfraedom
Copy link
Author

Thanks @brminnick for letting me know of your NuGet. At my company all third party libraries need to be reviewed and approved before been used. Having it as part of Xamarin would be preferable.

@brminnick
Copy link
Contributor

@rwaldenfraedom The code is all open source and you’re welcome to copy/paste my implementation into your code base.

@Insire
Copy link

Insire commented Mar 19, 2020

Any news on this? I'd like to rely on the official implementation, instead of copying pasting the code over.

@samhouts samhouts added the in-progress This issue has an associated pull request that may resolve it! label Sep 9, 2020
@rwaldenfraedom
Copy link
Author

YAY thanks @samhouts @StephaneDelcroix

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
in-progress This issue has an associated pull request that may resolve it! proposal-open t/enhancement ➕
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants