zak.taccardi
02/13/2023, 8:32 PMselectedId: String,
// the `selectedId` will always be in this list
options: List<IdWithDisplayName>
How do I properly use the selectedId
to lookup the displayName
in the list of options?zak.taccardi
02/13/2023, 8:33 PMderivedStateOf
may be my friend here? https://developer.android.com/jetpack/compose/side-effects#derivedstateofmkrussel
02/13/2023, 8:35 PMMyDropdown
. If that lookup is proving too slow, then doing a remember with the selectedId
and options
as keys could cache the search.
Also may want to consider an ImmutableList
so that Compose can optimize.Stylianos Gakis
02/13/2023, 8:37 PMval selectedDisplayName = remember(selectedId, options) {
options.first { it.id = selectedId }.displayName
}
And this should be good enough.