appyx
appyx copied to clipboard
Investigate ViewModel support + RetainedInstanceStore
Check if it makes sense to implement ViewModel support on top of RetainedInstanceStore. Similarly to this, one of the possible solutions:
-
Node
implementsViewModelStoreOwner
interface -
RetainedInstanceStore
stores and clearsViewModelStore
for everyNode
This will be really nice. I'm trying out appyx again today and I'm trying to figure out how to retain my presenter across config changes but only at a per node level.
Hi @saket you can already retain your presenter per Node level. Please check com.bumble.appyx.sandbox.client.mvicoreexample.MviCoreExampleBuilder
where we retain feature. To make it work per node level you simply need to provide the id of the node like this:
val feature = buildContext.getRetainedDisposable(buildContext.identifier) {
MviCoreExampleFeature(payload)
}
For non-rx classes check com.bumble.appyx.core.store.getRetainedInstance
Oh whoops I completely missed that. Apologies!
Any updates on how do we use viewModels with this?
Hi @LittleTasteOfHeaven, the ViewModel support is not integrated into the library yet, however, we have support for retaining objects. Similar functionality can be achieved using the RetainedInstance
API. Please check docs here
Thank you @KovalevAndrey ! Any eta when viewmodel support will land on appyx?