Hi, I wanted to know what's the point of mapping f...
# mvikotlin
l
Hi, I wanted to know what's the point of mapping from State to Model? Both seem to be pretty much the same? Couldn't we just do
Value<State>
? https://github.com/JetBrains/compose-jb/blob/master/examples/todoapp/common/main/s[…]mmonMain/kotlin/example/todo/common/main/integration/Mappers.kt
1
a
Yes, this is to decouple UI and the Store (business logic). Also the view model usually contains data in an easy to render format - e.g. strings may be formatted, icons etc. On the other hand, the state may contain additional data for the business logic, such as tokens for pagination, etc.
It's not quite possible to put this extension function in a library, because Decompose and MVIkotlin do not depend on each other. Adding additional dependencies is undesired.
l
Gotcha! Maybe a future interop library of some sort? Anyways, really loving your work! Thank you!
🎉 1
a
Couldn't a separate artifact be created that does depend on MVIKotlin with that extension function? Might be a little tedious when that library gets updated to also make sure its updated in decompose. But I would find it helpful because I find myself copying that extension function in every new project I setup with the two. Could also probably add the instance keeper ext in that 🤷
a
Adding a module to either Decompose or MVIKotlin that depends on another library is very undesired. Transitive dependencies may brink additional binary compatibility concerns. However there could be a standalone repository with helpers. I will support if somebody would create such a repository. Extensions for MVIKotlin and InstanceKeeper are already present in MVIKotlin, because it depends on Essenty anyway. https://github.com/arkivanov/MVIKotlin/blob/master/mvikotlin/src/commonMain/kotlin/com/arkivanov/mvikotlin/core/instancekeeper/InstanceKeeperExt.kt
a
That's a good point, another idea might be to just create a template repository to do the basic setup of a decompose/mvi project since I find myself doing a lot of copy paste to setup new projects with all the appropriate dependencies.