-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduced RetainedInstanceStore to keep data during config change #361
Introduced RetainedInstanceStore to keep data during config change #361
Conversation
dcf4973
to
626a79b
Compare
626a79b
to
af8cbce
Compare
Originally I wanted to suggest to adopt #322 instead, but after I checked API I do not want anymore (ViewModels API is a hell, you can't just pass ViewModel factory as a lambda). But my suggestion is still to apply its approach regarding Would like to invite more people to discuss. |
af8cbce
to
3685fa6
Compare
@CherryPerry I'm happy if we can come up with another solution. This PR allows Devs to retained objects within the builder which is useful of you're using MVICore. The ViewModel approach in the other PR doesn't seem to have this functionality. Perhaps we could support both? As devs using the builder/interactor approach need a solution as well |
3685fa6
to
18fd6ae
Compare
@@ -22,6 +26,18 @@ data class BuildContext( | |||
) | |||
} | |||
|
|||
fun <T : NodeCustomisation> getOrDefault(defaultCustomisation: T) : T = | |||
val identifier: String by lazy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this internal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment at the very least saying to not use it, Incubating?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot make this internal unfortunately. Not sure if I should mark this with a comment as this will be part of the 1.0 API
private val map: MutableMap<String, MutableMap<KClass<*>, ValueHolder<*>>> = HashMap() | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
override fun <T : Any> get(nodeId: String, clazz: KClass<*>, disposer: (T) -> Unit, factory: () -> T): T = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a string key instead of the class so that multiple instance of the same class can be used.
eca3a97
to
5d629d2
Compare
libraries/core/src/test/kotlin/com/bumble/appyx/core/store/RetainedInstanceStoreTest.kt
Outdated
Show resolved
Hide resolved
libraries/core/src/main/kotlin/com/bumble/appyx/core/store/RetainedInstanceStore.kt
Outdated
Show resolved
Hide resolved
libraries/core/src/test/kotlin/com/bumble/appyx/core/store/RetainedInstanceStoreTest.kt
Show resolved
Hide resolved
eb7fd4d
to
50d47f4
Compare
50d47f4
to
af69578
Compare
af69578
to
fe8d961
Compare
Description
Copied the RetainedInstanceStore concept from RIBs so that objects can be retained during a configuration change.
Also re-added the MVICore screens to the sandbox to demonstrate the behaviour
Check list
CHANGELOG.md
if required.