Flow 不 emit 数据,为什么会回调 onCompletion ?


#1

下面的代码没有 emit,没有回调 collect ,但是会回调 onCompletion ,怎么没收集到数据也能判断为完成了?这算是个 bug 么?

flow<Unit> {
  Log.d("flow", "do something")
}.onStart {
  Log.d("flow", "onStart")
}.onCompletion {
  Log.d("flow", "onCompletion")
}.collect {
  Log.d("flow", "collect")
}

京ICP备16022265号-2 Kotlin China 2017 - 2018