Big Chungus
02/15/2022, 8:20 AMOleksandr Karpovich [JB]
02/15/2022, 9:14 AMWhat's the reasoning..The idea behind that change in 1.1.0-... was to align with upstream compose's effects and reuse them rather than custom effects. For example, DisposableEffect api supports multiple keys and SideEffect supports no keys at all (unlike DomSideEffect).
It's now doable with RefEffectit's also doable using DisposableEffect in the content of an element:
DisposableEffect(key...) {
scopeElement // this is a reference to an element
onDispose { } // onDispose is mandatory though
}
propagating compose state changes to external stateCompose's SideEffect can be used for that. I guess you want to have an access to an element reference within SideEffect, right? Could you please show some code snippet with effects where you want to access the reference?
Big Chungus
02/15/2022, 9:25 AMBig Chungus
02/15/2022, 9:26 AMBig Chungus
02/15/2022, 9:28 AMOleksandr Karpovich [JB]
02/15/2022, 9:31 AMvararg keys: Any?
? Do they ever change in your case?
I'm trying to think if we can provide a ref to an element within SideEffect (it doesn't have keys). Would it help you? Do you need those keys for some reason?Big Chungus
02/15/2022, 9:35 AMBig Chungus
02/15/2022, 9:35 AMOleksandr Karpovich [JB]
02/15/2022, 9:45 AMpublic fun <MDC : MDCBaseModule.MDCComponent<*>> ElementScope<*>.MDCSideEffect(
vararg keys: Any?,
effect: Builder<MDC>
) {
keys.forEach { key ->
DomSideEffect(key) {
it.mdc(effect)
}
}
}
as for accessing a reference in SideEffect, we'll think about it once again. Maybe even some sort of __reallyUnsafeElementRef
could be added (still not very good I think).Big Chungus
02/15/2022, 9:46 AMOleksandr Karpovich [JB]
02/15/2022, 9:47 AMBig Chungus
02/15/2022, 9:48 AMBig Chungus
02/15/2022, 9:49 AMBig Chungus
02/15/2022, 9:49 AMBig Chungus
02/15/2022, 10:10 AMOleksandr Karpovich [JB]
02/15/2022, 10:14 AMBig Chungus
02/15/2022, 10:22 AMOleksandr Karpovich [JB]
02/15/2022, 10:29 AMBig Chungus
02/15/2022, 10:30 AMBig Chungus
02/15/2022, 10:33 AMOleksandr Karpovich [JB]
02/15/2022, 10:40 AMAdam Powell
02/15/2022, 12:25 PMAdam Powell
02/15/2022, 12:31 PMBig Chungus
02/15/2022, 12:32 PMBig Chungus
02/15/2022, 12:35 PMBig Chungus
02/15/2022, 2:16 PMmdcComponent
ย is only attached to native DOM element because I couldn't think of a better way to make it accessible to the composition scope later on.Big Chungus
02/15/2022, 2:17 PMDominaezzz
02/15/2022, 7:06 PMBig Chungus
02/15/2022, 8:03 PMDominaezzz
02/15/2022, 8:04 PMDominaezzz
02/15/2022, 8:05 PMDomSideEffect
is named after me. ๐Big Chungus
02/15/2022, 10:13 PM[JB] Shagen
02/16/2022, 7:15 PMBig Chungus
02/16/2022, 7:45 PM