Comments (4)
I have the same issue, and am looking at ReverseInit(), which is supposed to be invoked when the page is popped from the navigation stack. However, I'm not seeing it get invoked when I pop the page using CoreMethods.PopPageModel(). I suspect that ReverseInit() is invoked not on the pagemodel that was popped, but on the pagemodel that pushed it. So, in that case, it isn't appropriate for disposing subscriptions.
I see that Prism's BaseViewModel implements IDestructible - see the bottom of this page: https://prismlibrary.com/docs/xamarin-forms/creating-your-first-prism-app.html#anatomy-of-a-prism-application
@yevgeny-sotnikov did you find out another way using FreshMVVM ?s
@rid00z Is there something like this? Would be great to have this as it's a very common use case.
from freshmvvm.
I have the same issue, and am looking at ReverseInit(), which is supposed to be invoked when the page is popped from the navigation stack. However, I'm not seeing it get invoked when I pop the page using CoreMethods.PopPageModel(). I suspect that ReverseInit() is invoked not on the pagemodel that was popped, but on the pagemodel that pushed it.
ReverseInit()
needed to pass some result back to view-model, so it isn't applicable for our use-case.
@tele-bird unfortunatelly i still have this issue, no any proper ways to understand that page is destroying
from freshmvvm.
Maybe the PageWasPopped event could suffice? Though it says that it might not be raised every time a page is popped, so probably not suitable to completely avoid memory leaks unless it is improved.
cc: @yevgeny-sotnikov , @rid00z
from freshmvvm.
@yevgeny-sotnikov
I recently discovered the FreshBasePageModel.PageWasPopped event, and I think it can be used for the important memory-conserving best-practices that you need. It is better than using ViewIsAppearing/ViewIsDisappearing because it only fires when you don't need it any more. Along with unsubscribing from events, I plan to use it to implement Disposable pattern, for IDisposable objects referenced by my pages. Hope this helps!
In my implementation, my base class unsubscribes from further notifications after the first one (line 10), since the page is quite unlikely to be popped a 2nd time!
public class BasePageModel : FreshBasePageModel
{
public BasePageModel(IConnectivity connectivityService)
{
PageWasPopped += HandlePageWasPopped;
}
private void HandlePageWasPopped(object sender, EventArgs e)
{
PageWasPopped -= HandlePageWasPopped;
OnPagePopped(sender, e);
}
protected virtual void OnPagePopped(object sender, EventArgs e)
{
}
}
from freshmvvm.
Related Issues (20)
- CoreMethods PopPageModel() throws exception when page contains CarouselView HOT 1
- using <Path> in XAML throws TinyIoCResolutionException
- ReverseInit not called HOT 1
- XF 5 MasterDetailPage to FlyoutPage HOT 1
- Correct way to handle Button Clicks and updating the model HOT 1
- Hamburger Menu is displayed in the Content Page in Landscape Orientation - Android HOT 1
- Project status and plans for .NET MAUI HOT 10
- Page not loaded properly for PopPageModel using navigation stack in FreshMVVM Xamarin Forms Android HOT 1
- SetBackButtonTextProperty doesn't work HOT 1
- How to intercept software back button press on FreshMVVM PageModel? HOT 3
- v4.0 Release notes?
- SIGABRT: Popped page does not appear on top of current navigation stack, please file a bug. IOS Xamarin HOT 2
- Can not run sample App in VS2019
- Fody Propertychanged on Viewmodels
- PushPageModel does not work after the app ran in the background
- Update view after update bind property in ViewModel
- Cannot resolve IFreshNavigationService from a page loaded from Notifcation tap HOT 1
- FreshMVVM MAUI support
- Issue 'NavGraph cannot be null' with FreshMasterDetailNavigationContainer since MAUI 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from freshmvvm.