Tim Malseed
03/16/2021, 2:02 AMTim Malseed
03/16/2021, 2:03 AMval exerciseProgressMap: LinkedHashMap<Exercise, MutableStateFlow<ExerciseProgress>> = linkedMapOf()
Tim Malseed
03/16/2021, 2:04 AMTim Malseed
03/16/2021, 2:05 AMTim Malseed
03/16/2021, 2:07 AMTim Malseed
03/16/2021, 2:09 AMval exerciseProgressMap: MutableStateFlow<LinkedHashMap<Exercise, ExerciseProgress>> = MutableStateFlow(linkedMapOf)
But now I need to emit a whole new map of Exercise and ExerciseProgress, each time the progress changesdarkmoon_uk
03/16/2021, 2:19 AMMutableStateFlow<LinkedHashMap<Exercise, MutableStateFlow<ExerciseProgress>>>
darkmoon_uk
03/16/2021, 2:20 AMTim Malseed
03/16/2021, 2:23 AMdarkmoon_uk
03/16/2021, 2:24 AMExercise
of interest; and `flatMapLatest`s on exerciseProgressMap
to maintain awareness of that particular progress. E.g:
fun exerciseProgress(exercise: Exercise) : StateFlow<ExerciseProgress?> = exerciseProgressMapFlow.flatMapLatest { progressByExercise -> progressByExercise[exercise] ?: flowOf(null) }
darkmoon_uk
03/16/2021, 2:26 AMnulled
for observers too; i.e. preventing them seeing stale data.darkmoon_uk
03/16/2021, 2:27 AMnulls
based on sealed classes; but this illustrates the concept.Tim Malseed
03/16/2021, 2:29 AMMutableStateFlow<LinkedHashMap<Exercise, MutableStateFlow<ExerciseProgress>>>
vs
MutableStateFlow<LinkedHashMap<Exercise, ExerciseProgress>>
darkmoon_uk
03/16/2021, 2:30 AMdarkmoon_uk
03/16/2021, 2:31 AMTim Malseed
03/16/2021, 2:32 AMdarkmoon_uk
03/16/2021, 2:32 AMFlow
of single exercise change; you limit the impact on other areas of the App in a minimal and consistent way.darkmoon_uk
03/16/2021, 2:33 AMTim Malseed
03/16/2021, 2:34 AMdarkmoon_uk
03/16/2021, 2:35 AMTim Malseed
03/16/2021, 2:36 AMdarkmoon_uk
03/16/2021, 2:38 AMdarkmoon_uk
03/16/2021, 2:44 AMAdam Powell
03/16/2021, 3:00 AMval exerciseProgressMap = mutableStateMapOf<Exercise, ExerciseProgress>()
Adam Powell
03/16/2021, 3:01 AMAdam Powell
03/16/2021, 3:02 AMTim Malseed
03/16/2021, 3:04 AMval exerciseProgressMap: MutableStateFlow<Map<Exercise, ExerciseProgress>>
Right?Adam Powell
03/16/2021, 3:12 AMTim Malseed
03/16/2021, 3:15 AMZach Klippenstein (he/him) [MOD]
03/16/2021, 4:53 AMAdam Powell
03/16/2021, 4:55 AMmutableStateMapOf
is implemented 😄