Kshitij Patil
01/30/2021, 4:40 PMval fieldFocus = remember { FocusRequester() }
LaunchedEffect(key1 = Unit) {
addressFocus.requestFocus()
}Zach Klippenstein (he/him) [MOD]
01/30/2021, 5:25 PMrequestFocus is suspending), I would use SideEffect instead of LaunchedEffect.grandstaish
01/30/2021, 7:34 PMDisposableEffect? I think SideEffect runs after every recomposition. (Asking bc I’m using DisposableEffect to replace my onCommit calls, but having an empty onDispose lambda feels weird to me, so want to check I’m not missing an obvious API)Ian Lake
01/30/2021, 7:49 PMonCommit -> SideEffect. It is supposed to feel wrong using DisposableEffect if you have nothing to disposeZach Klippenstein (he/him) [MOD]
01/30/2021, 7:53 PMSideEffect replaced onActive, not onCommit).grandstaish
01/30/2021, 7:53 PMonCommit took a subject though right? Which SideEffect doesn’t as far as I can seegrandstaish
01/30/2021, 7:54 PMDisposableEffect(Unit) {
// do thing
onDispose { }
}Ian Lake
01/30/2021, 8:14 PMDisposableEffect(Unit) is the equivalent to onActive, looking at the commit that made the changes: https://android-review.googlesource.com/c/platform/frameworks/support/+/1548515Andrew Neal
01/30/2021, 8:20 PMonDispose, but I think that is the correct way to handle things right now. There isn't another effect api to use in place of it at the moment. If you want to save yourself some typing, you could make your own DisposableEffect with an empty onDispose and just import that one when you need it. Here are some examples with empty onDispose calls:
Modifier.focusable
Swipeable.rememberSwipeableStateFor
Modifier.swipeable
NavHost
DemoFilter.FilterFieldgrandstaish
01/30/2021, 8:25 PMIan Lake
01/30/2021, 8:40 PMDisposableEffect without any parameters is "usually incorrect" to use @Adam Powell's wordsAdam Powell
01/30/2021, 8:42 PMonDispose clauseAdam Powell
01/30/2021, 8:42 PMAdam Powell
01/30/2021, 8:43 PMAdam Powell
01/30/2021, 8:45 PMMantas Varnagiris
01/31/2021, 12:48 PMKshitij Patil
01/31/2021, 12:49 PMLaunchedEffect because it's called once at the start and on subject changed afterwards, which in my case is Unitallan.conda
02/02/2021, 6:38 AMKshitij Patil
02/02/2021, 9:17 AMimePadding() or navigationBarsWithImePadding() to prevent TextField from getting hidden by the Keyboard but now I'm using it everywhere I've TextField . This wasn't a case with native xml layouts. softInputMode=adjustResize in AndroidManifest and fitsSystemWindow=true used to do the job for us.allan.conda
02/02/2021, 9:23 AMKshitij Patil
02/02/2021, 9:34 AMShakil Karim
02/14/2021, 10:01 AMDisposableEffect(ColorToApply) {
systemUIController.setStatusBarColor(ColorToApply)
onDispose {
systemUIController.setStatusBarColor(colorPrimary)
}
}Adam Powell
02/14/2021, 2:29 PMAdam Powell
02/14/2021, 2:31 PMAdam Powell
02/14/2021, 2:35 PMShakil Karim
02/18/2021, 5:27 PM