Joseph Hawkes-Cates
04/11/2022, 6:15 PMCsaba Szugyiczki
04/11/2022, 6:24 PMAdam Powell
04/11/2022, 6:24 PMpainterResource
is not subscribing to configuration changes the way the other resource functions doCsaba Szugyiczki
04/11/2022, 6:25 PM@Composable
fun myPainterResource(@DrawableRes id: Int): Painter {
LocalConfiguration.current
return painterResource(id = id)
}
Joseph Hawkes-Cates
04/11/2022, 6:28 PMAdam Powell
04/11/2022, 6:31 PMJoseph Hawkes-Cates
04/11/2022, 6:34 PMCsaba Szugyiczki
04/11/2022, 6:34 PMAdam Powell
04/11/2022, 6:38 PMmyPainterResource
to recompose, but that doesn't mean painterResource
can't skip at some point if it believes nothing else it would return has changedColton Idle
04/11/2022, 6:38 PMAdam Powell
04/11/2022, 6:39 PMpainterResource
causing a re-check and reload of related things, if it does today, is also coincidentalJoseph Hawkes-Cates
04/11/2022, 6:42 PMAlex Vanyo
04/11/2022, 6:43 PMmyPainterResource
differ from how `stringResource`s invalidate themselves?
@Composable
@ReadOnlyComposable
private fun resources(): Resources {
LocalConfiguration.current
return LocalContext.current.resources
}
Csaba Szugyiczki
04/11/2022, 6:45 PMAdam Powell
04/11/2022, 6:45 PMpainterResource
accepts only an Int
as an argument, which would make it otherwise stable; there's no affirmative signal that painterResource
must recompose if its caller recomposesAlex Vanyo
04/11/2022, 6:49 PMLocalConfiguration.current
without actually using the value) to “bubble up” to callers to force recomposition, but not to “bubble down” to other callsAdam Powell
04/11/2022, 6:50 PMpainterResource
too you can see and imagine all sorts of other valid implementations that wouldn't trigger a reload of the resource from an outer recomposition eitherAlex Vanyo
04/11/2022, 6:54 PMLooking around that code more, I think onlyis not subscribing to configuration changes the way the other resource functions dopainterResource
stringResource
and company are subscribing to configuration changes, so probably everything else should also do so? booleanResource
, dimensionResource
, etc.Adam Powell
04/11/2022, 6:55 PMAlex Vanyo
04/11/2022, 6:57 PMbooleanResource
should probably handle 😄Joseph Hawkes-Cates
04/11/2022, 6:58 PM