Last active
July 16, 2022 17:24
-
-
Save benigumocom/baea7a91a8d8fc985333678373d382d0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun <T> Flow<T>.log(label: String, tag: String = "###"): Flow<T> { | |
| val prefix = "$tag [$label] ${this.javaClass.simpleName}" | |
| return this | |
| .onStart { | |
| Timber.d("$prefix onStart()") | |
| } | |
| .onEach { value -> | |
| Timber.d("$prefix onEach() value = $value") | |
| } | |
| .onCompletion { cause -> | |
| Timber.d("$prefix onCompletion() cause = $cause") | |
| } | |
| .onEmpty { | |
| Timber.d("$prefix onEmpty()") | |
| } | |
| } |
Author
Author
【Kotlin】Flow の挙動やライフサイクルをログで確認する
👉 https://android.benigumo.com/20220505/flow-lifecycle/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Flow - Search result - android.benigumo.com
👉 https://bit.ly/3ECgzeu