pardom
05/24/2020, 6:41 PMMichal Harakal
06/01/2020, 4:34 PMcontramap
for binding MVU model to Jeppack’s model. But I don’t get it about lifecycle, who is reposnsible for that? I’ve seen in other sample use of Android’s ViewModel bound with using observeAsState
to Jetpack. Also you are using `@Model`which is already deprecated with dev12.
Also looking forward to see iOS part …pardom
06/01/2020, 5:08 PMApplication
process and is therefore independent of any Activity
. When an Activity
(in this case there is only one) has a configuration change (e.g. orientation change), it will first remove its render function from the runtime here: https://github.com/pardom/lambda-news/blob/master/lambda-news/android-compose/src/main/java/news/lambda/android/AppActivity.kt#L46. Then when the new activity is created, it will provide its render function to the runtime here: https://github.com/pardom/lambda-news/blob/master/lambda-news/android-compose/src/main/java/news/lambda/android/AppActivity.kt#L42. That is all that is needed handle configuration change because the runtime is not part of the activity.
An Oolong user may not like this approach, in which case you can host the runtime in a ViewModel
. The UI state is managed by the runtime and job of Android/Compose is to simply provide dependencies and render UI.contramap
, this has nothing to do with the lifecycle, but rather delegation to child components (i.e. screens). The root component of the app delegates to child components by wrapping their model/msg/props. contramap
is a function that allows you to easily map from a child Dispatch<ChildMsg>
to the root `Dispatch<AppMsg>`: https://github.com/pardom/lambda-news/blob/master/lambda-news/view/src/main/kotlin/news/lambda/app/component/AppComponent.kt#L45contramap
should help in understanding it: https://github.com/oolong-kt/oolong/blob/master/oolong/src/commonMain/kotlin/oolong/dispatch/util.kt#L36Dispatch<A>
, a function (B) -> A
, and returns a Dispatch<B>
.contramap
which helps in delegating from a parent Next
to a child Next
. https://github.com/oolong-kt/oolong/blob/master/oolong/src/commonMain/kotlin/oolong/next/util.kt#L50@Model
I plan to migrate soon, but I’m waiting for the next version of AS Preview. Canary 10 is pretty laggy. 😬Michal Harakal
06/01/2020, 6:25 PMpardom
06/01/2020, 6:54 PMfor me is important to know, that ModelView is not necessary and we can have perfectly multiplatform sharable code with MVU (stiil keeping iOS in mind), just reimplementing the render function.That was one of the primary goals with Oolong. The platform is not the problem domain, so it shouldn't be coupled to your domain logic. Nor should it concern itself with what to render, but rather how.