ursus
10/22/2025, 12:21 AMMutableSharedFlow (that acts as a trigger to refresh stuff), that has a default value (so syncs get triggered right away on start)?
I find manually throwing in `trigger.emit(Unit)`after everyone is subscriber a bit awkwards
Unless there is an API I'm not aware of, probably the best would be to have own subclass right? Like this maybe?
class TriggerFlow : Flow<Unit> {
private val _trigger = MutableSharedFlow<Unit>(
replay = 1
)
init {
_trigger.tryEmit(Unit)
}
suspend fun trigger() {
_trigger.emit(Unit)
}
override suspend fun collect(collector: FlowCollector<Unit>) {
_trigger.collect(collector)
}
}
How does this look? Is the tryEmit in init cool?streetsofboston
10/22/2025, 12:43 AMonStart callback.ursus
10/22/2025, 12:43 AMstreetsofboston
10/22/2025, 12:46 AMcreateOrGetMySharedFlow().onStart { emit(Unit) }..... collect { ... } should work, I thinkstreetsofboston
10/22/2025, 12:47 AMursus
10/22/2025, 12:47 AMstreetsofboston
10/22/2025, 12:49 AM