Xavier Lian
10/04/2019, 1:56 AMclass MyVM(
private val vmDidSummonLoadingScreen: () -> Unit,
private val vmDidDismissLoadingScreen: () -> Unit
)
{
fun doAFlip()
{
vmDidSummonLoadingScreen()
startSuperLongAsyncTask {
vmDidDismissLoadingScreen()
}
}
}
Here’s some example UI in Android
class FMMain: Fragment()
{
val loadingScreenVw: View get() = fm_main_vw_loading_screen //From XML
val vm: MyVM by lazy { //Problem a1
MyVM(
vmDidSummonLoadingScreen = { //Problem a0
loadingScreenVw.visibility = View.VISIBLE
},
vmDidDismissLoadingScreen = { //Problem a0
loadingScreenVw.visibility = View.GONE
}
)
}
override fun onCreate(...)
{
super.onCreate(...)
vm.doAFlip()
}
}
Problems:
a0: The lambdas will leak the instance of FMMain since the lambdas reference a property of FMMain thereby implicitly capturing it.
a1: Assuming the lambdas don’t leak, when the device rotates, the UI dies and so does the VM. There is the Android Component Library ViewModel class that solves this, but that can’t be used in the shared module.
iOS is excluded because this architecture works pretty well since Swift has [weak self] to prevent strong captures.
So my questions are:
1: How does one release lambda captures?
1.1: If not possible, what is the best way to let the UI layer know that an event happened in the VM without using any external libs/dependencies (just idomatic kotlin)?
2: Only in Android, I am considering wrapping my VM with an object that inherits from Android’s Architecture Components’ ViewModel (possibly generic idk if I can do that yet). Is there a better alternative in your opinion?
3. In your opinion, should VMs be injected into Fragments, or should Fragments instantiate and own their own VMs?napperley
10/04/2019, 2:35 AMBig Chungus
10/04/2019, 3:55 PMNikky
10/05/2019, 7:33 PMKonstantin Petrukhnov
10/07/2019, 6:28 AMKris Wong
10/08/2019, 6:54 PMkpgalligan
10/08/2019, 7:33 PMKris Wong
10/09/2019, 3:27 PMapply(plugin = "com.android.library")
in build scripts written in Kotlin DSL?Sujit
10/09/2019, 8:25 PMankushg
10/10/2019, 6:26 PM@OptionalExpectation
only works for annotations at the moment, and doesn't automatically create no-op implementations for interfaces, right?Abel
10/11/2019, 7:05 AMmkojadinovic
10/11/2019, 10:37 AMdiesieben07
10/11/2019, 8:19 PMjsMain/resources
, but those files never show up in the NPM project that's generated by the gradle plugin.
Moreover: I am applying the "multiplatform" plugin in a subproject, but the javascript npm projects are still generated in the top level project build folder and there is also an NPM project generated for the top level project (which does not have the multiplatform plugin!). The NPM project that actually contains my js code is put into build/js/packages/<root project name>-<subproject name>
. How can I disable this? I just want a plain NPM project for the javascript code.Nikolai
10/13/2019, 4:37 PMkpgalligan
10/13/2019, 5:35 PMbinaries {
framework {
export project(':dependency')
// Export transitively.
transitiveExport = true
}
}
Config block from here: https://kotlinlang.org/docs/reference/building-mpp-with-gradle.htmlKonstantin Petrukhnov
10/14/2019, 10:40 AMKris Wong
10/15/2019, 1:47 PMtimm
10/16/2019, 7:19 AMRobert Jaros
10/16/2019, 1:24 PMcommonMain
sourceSet in multiplatform gradle project?Robert Jaros
10/16/2019, 5:07 PMjvm
target trigger the compilation of the commonMain
?darkmoon_uk
10/17/2019, 7:54 AMFranGSierra
10/17/2019, 10:25 AMMap<Field,Value>
for pass it to iOS library.Lamberto Basti
10/17/2019, 12:58 PMconfigurations["jsApi"].singleFile
it errors with:
Resolving configuration 'jsApi' directly is not allowed
taso
10/17/2019, 6:48 PMAndy Gibel
10/17/2019, 7:48 PMFranGSierra
10/18/2019, 12:01 PMapp -> Run all tests
there are no tests founds. I need to run individually the folders of each platform and on iOS case I need to run the gradle script for it. Any idea about how to unify this?zceejkr
10/19/2019, 8:17 AMeloew
10/19/2019, 11:33 AMmzgreen
10/19/2019, 2:49 PMNoClassDefFoundError
in jvm module. It doesn’t see the class from shared module 🤔CRamsan
10/21/2019, 4:50 AMCRamsan
10/21/2019, 4:50 AMlouiscad
10/21/2019, 4:55 AMKris Wong
10/21/2019, 1:37 PM