组合kotlin单元流量而无需转换功能
我目前有两个共享流量,我需要合并来做某事,但是我真的不需要转换功能的结果,我只想知道两个“事件”是否已经开始。在实施此功能时,我得到了这个无用的支架主体:
combine(
flow1, // SharedFlow<Unit>
flow2, // SharedFlow<Unit>
) { _, _ ->
// Useless function body
}.onEach {
// Do some work
}.launchIn(scope)
有没有一种方法可以更干净地做到这一点,而无需转换功能?
I have currently two SharedFlows that I need to combine to do something, but I don't really need the result from the transformation function, I only want to know if both "events" started yet. While implementing this I get this useless bracket body:
combine(
flow1, // SharedFlow<Unit>
flow2, // SharedFlow<Unit>
) { _, _ ->
// Useless function body
}.onEach {
// Do some work
}.launchIn(scope)
Is there a way I can do this more cleanly without the need for the transform function?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在“无用功能主体”中“做一些工作”,而不是::
You can "Do some work" in "Useless function body" instead of
onEach
: