ReactiveUI icon indicating copy to clipboard operation
ReactiveUI copied to clipboard

Xamarin.Forms does not have a view lifecycle/activation hook, someone should PR it into Xamarin.Forms

Open ghuntley opened this issue 9 years ago • 8 comments
trafficstars

Xamarin Forms still does not have a view lifecycle/activation hook, someone should PR it into Xamarin.Forms now that it is open source. Kent has the details and can act as a mentor for anyone whom wishes to help make this happen.

If you want to make self-contained reactive views with RxUI prior to the XF issue being addressed, you're not ​_completely_​ dead in the water - see https://gist.github.com/kentcb/d8f310a4db40cc6833c5df48fa2de31a (for v7 upwards)

ghuntley avatar Jul 08 '16 00:07 ghuntley

There is an activity Rx lifecycle hook in Java from Trello https://github.com/trello/RxLifecycle and something similar from Airbnb https://github.com/airbnb/RxGroups.

Frameworks like https://github.com/bluelinelabs/Conductor use the activity lifecycle callback. Such as https://github.com/bluelinelabs/Conductor/blob/557e4c2122a145c44be7a3a51945174c02489b8c/conductor/src/main/java/com/bluelinelabs/conductor/internal/LifecycleHandler.java

mtilbrook-dev avatar Jul 08 '16 23:07 mtilbrook-dev

This is a big issue. Pages have OnAppearing, but Views don't. How are we supposed to know when the control put on screen?

MelbourneDeveloper avatar Feb 17 '17 02:02 MelbourneDeveloper

See also: https://forums.xamarin.com/discussion/84510/proposal-improved-life-cycle-support

kentcb avatar Feb 17 '17 02:02 kentcb

@MelbourneDeveloper btw, the only recourse I have found is to forward life cycle events from the host page to any views within it that need to activate/deactivate. It's a bit annoying, but it works. Of course, we want to improve the story a lot moving forward, hence the XF proposal.

kentcb avatar Feb 17 '17 02:02 kentcb

I'm going to use the OnParentSet method which sucks but will probably do the job until this is fixed.

MelbourneDeveloper avatar Feb 17 '17 03:02 MelbourneDeveloper

Microsoft announced at build they are adding these hooks into XF.

ghuntley avatar May 20 '18 11:05 ghuntley

@PureWeen What's the status on this one?

glennawatson avatar Jun 14 '19 13:06 glennawatson

Unfortunately we weren't able to get this into 4.0 because the implementation wasn't quite right

I have parts of that work accomplished here for shell https://github.com/xamarin/Xamarin.Forms/pull/6527

This takes a couple steps forward with setting up Appearing to actually represent Appearing opposed to Appeared. Once that's in I'm hoping to propagate that down to the View level then work on appeared.

Out of curiosity would you make use of an Appeared event at all?

It seems like for MVVM Appearing is most important.

PureWeen avatar Jun 14 '19 18:06 PureWeen