Summary
As one of the authors of ReactiveUI, I have found that Xamarin.Forms does not provide the requisite view life cycle hooks to enable the framework to manage the activation and deactivation of resources in response to the comings and goings of views.
Specifically, I have found these problems:
Page.Appearing
actually fires in response toViewDidAppear
on iOS. One of ReactiveUI's benefits is its code-based, type-safe binding infrastructure.Appearing
is the only hook we can use to get stuff on the screen, but it fires too late on iOS, so there is a brief period where the screen is not populated with data. I have already attempted to start a discussion here, but it seemed to stagnate.Given a
View
, there is no way to tell when thatView
appears and disappears from the screen. There is noView.Appearing
orView.Disappearing
events as there is forPage
. It might seem appropriate to therefore search up the visual tree for thePage
and hook into that. However, this is inefficient (but perhaps that's inevitable) and there is no means of knowing when thePage
itself changes. There is noPageChanged
event, andPropertyChanged
does not fire in response to thePage
changing.
API Changes
Page.Appearing
should fire in response toViewWillAppear
on iOS. Moreover, there should bePage.Appeared
andPage.Disappeared
counterparts. Yes, this is potentially breaking to people who are hooked intoAppearing
and rely on it firing in response toViewDidAppear
on iOS. However, that behavior has always been incorrect and the fix for these people is literally to changeAppearing
toAppeared
(or hold off on the XF upgrade).Ideally, add
Appearing
,Appeared
,Disappearing
,Disappeared
toView
and have them Just Work. Failing that, ensure there is a hook by which framework authors can know the hostingPage
for aView
has changed. Perhaps a specificPageChanged
event, or just ensuringPropertyChanged
works as expected in this scenario.
Intended Use Case
The use case here is to give framework authors what they need to facilitate the creation of self-sufficient, standalone, encapsulated components by framework consumers. I specifically work on ReactiveUI, but other framework authors will/have run into the same issues.
ModEdit - Spec incoming ASAP