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.
Hi Folks,
I was using this library and wanted to unregister some events inside Dispose method of VIewModel but could not find a best way to call it.
So I did some changes inside MVVMComponentBase to call the Dispose method of the Binding Context if it is disposable.
Should I raise a PR as this might be useful for others as well or do you have any better suggestion?
The view model gets injected into the component via DI. Injected services should never be disposed as docs say:
The container calls Dispose for the IDisposable types it creates. Services resolved from the container should never be disposed by the developer. If a type or factory is registered as a singleton, the container disposes the singleton automatically.
This means that the component should never dispose the view model. Just implementing IDisposable in your view model is enough to make this work.
@klemmchr You are right as per the documentation one should not call Dispose but if you look at the example provided by microsoft, the dispose method is called on each refresh of the page but why would one refresh the page to call Dispose? and during my testing as well the Dispose method is called on Page Refresh.
"The debug console shows the following output after each refresh of the Index page:" ~Microsoft
In my View there could be two way to solve this problem
via Dispose
Invoking an event say page closed in view model on dispose.
Hi Folks,
I was using this library and wanted to unregister some events inside Dispose method of VIewModel but could not find a best way to call it.
So I did some changes inside MVVMComponentBase to call the Dispose method of the Binding Context if it is disposable.
Should I raise a PR as this might be useful for others as well or do you have any better suggestion?
Below is the PR: #56
The text was updated successfully, but these errors were encountered: