zjuhasz
08/14/2019, 12:55 AMChannel
or Flow
based API for my library and I’m having a hard time. I’m looking for some info / opinions / suggestions. I posted on the forum with all the info: https://discuss.kotlinlang.org/t/deciding-between-flows-and-channels/13858serebit
08/14/2019, 12:58 AMzjuhasz
08/14/2019, 1:01 AMChannel
-> Flow
-> Channel
which defeats the purpose of why I’m consider flows which is primarily to avoid launching a coroutine for these intermediate steps.Pablichjenkov
08/14/2019, 1:20 AMDominaezzz
08/14/2019, 1:20 AMPablichjenkov
08/14/2019, 1:22 AMDominaezzz
08/14/2019, 1:22 AMgildor
08/14/2019, 1:47 AMgildor
08/14/2019, 1:48 AMFor me, it’s more of an eager vs lazy thing. (and that ^) (edited)That is the point! Flow may be lazy and eager or cold and hot depending on implementation, channel is always eager and hot The main thing that Flow is more universal primitive, more safe (no need to expose any resources management mechanisms, or ask user of your API to close channel etc) and just easy to use by consumer of your API
zjuhasz
08/14/2019, 2:06 AMZach Klippenstein (he/him) [MOD]
08/14/2019, 6:07 PMmap
) between them. E.g. channelFlow
, BroadcastChannel.asFlow
, produceIn
, buffer
, flowOn