Wai-Wai Ng
11/07/2022, 5:02 PMgetUsdEurRate()
function is expensive, so essentially what I want is:
• Every consumer registers somewhere
• When there is an active registration, the function gets kicked off and all the consumers suspend until we get a value back
◦ As other consumers may register while the function is running
• No consumer should ever get a stale value
My first approach was to use a 0-capacity synchronization channel, but based on the above thread, it sounds like channels don't really support both "no buffered values" and "multiple consumers get the same value". Is a flow the right approach here? Or something else?jw
11/07/2022, 5:06 PMKevin Del Castillo
11/07/2022, 5:06 PMMutableSharedFlow
Sam
11/07/2022, 5:35 PMKevin Del Castillo
11/07/2022, 5:37 PMDeferrable
using async
, right? 🤔rocketraman
11/08/2022, 1:45 AMgildor
11/08/2022, 3:33 AMWai-Wai Ng
11/08/2022, 11:02 AMefemoney
11/08/2022, 11:56 AMflow { getUsdEurRate() }
.shareIn(scope, SharingStarted.Lazily)
OR
val shared = MutableSharedFlow()
shared.onSubscription { getUsdEurRate() }
jw
11/08/2022, 12:31 PM