Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for IDestructilbe in WPF projects #1296

Closed
weitzhandler opened this issue Dec 8, 2017 · 6 comments
Closed

Support for IDestructilbe in WPF projects #1296

weitzhandler opened this issue Dec 8, 2017 · 6 comments
Labels

Comments

@weitzhandler
Copy link

weitzhandler commented Dec 8, 2017

Package info

  • Platform: WPF
  • Prism version: 6.3

Repro steps

Looks like the interface IDestructible is only available in XF.

I'm looking for a way to unsubscribe from events of objects injected to the VM before the VM needs to get collected/disposed of in WPF.

Is there a different way to achieve this?

*Some event sources aren't IoC ruled and EventAggregator is not always a feasible solution.

@noufionline
Copy link
Contributor

Subscribe has an overload which has a predicate to control the subscription. Check IsActive on the predicate then it will not fire when view is not active.

Subscribe(action, ThreadOption.PublisherThread, false, payload=> IsActive);

@weitzhandler
Copy link
Author

weitzhandler commented Dec 8, 2017

Would still be nice to have IDestructible in WPF too, to give us a hint on VM tear-down.

@brianlagunas
Copy link
Member

You can write a custom region behavior to accomplish this in your app. This will most likely not be included in Prism as I cannot assume that when a view is removed from a region that it will not be reused again.

@brianlagunas
Copy link
Member

I've actually decided to include this. If someone is trying to reuse VM's after they have been removed from a Region, then it is the developers responsibility not to "clean them up" or even implement this interface.

@brianlagunas
Copy link
Member

Done!

@lock
Copy link

lock bot commented Jan 28, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants