I have a callbackFlow below
fun <T> Flow<T>.callbackMerge(other: Flow<T>): Flow<T> = callbackFlow {
channel.close()
launch {
collect { trySend(it) }
channel.close()
}
other.collect { trySend(it) }
awaitClose { println("Close Callback") }
}
I can use channel.close()
or close()
. They seem to behave the same to me.
Is there a different between them? When should I use which?
The docs of
channel
property say:So basically they are the same due to delegation.