Michael Marshall
03/03/2022, 4:12 AMFlow<UnmappedValue>
into a Map<SomeKey, Flow<MappedValue>>
? Like the opposite of merge
? Maybe explode
or subFlows
or something like that?wasyl
03/03/2022, 7:19 AMFlow
continuously add to a mutable map?Michael Marshall
03/03/2022, 12:04 PMfun <Key, Input, Result> Flow<Input>.toMapOfFlowsBy(mapping: Map<Key, (Key, Input) -> Result>): Map<Key, Flow<Result>> =
mapping.mapValues { (key, transform) -> map { transform(key, it) } }
You could also do the same thing with a List
if you wanted