@@ -13,7 +13,6 @@ import androidx.lifecycle.lifecycleScope
13
13
import androidx.lifecycle.repeatOnLifecycle
14
14
import androidx.recyclerview.widget.RecyclerView
15
15
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
16
- import kotlinx.coroutines.ExperimentalCoroutinesApi
17
16
import kotlinx.coroutines.Job
18
17
import kotlinx.coroutines.channels.awaitClose
19
18
import kotlinx.coroutines.flow.Flow
@@ -22,9 +21,11 @@ import kotlinx.coroutines.flow.collect
22
21
import kotlinx.coroutines.launch
23
22
24
23
fun interface FlowTransformer <I , O > {
24
+ @CheckResult
25
25
fun transform (input : Flow <I >): Flow <O >
26
26
}
27
27
28
+ @CheckResult
28
29
@Suppress(" NOTHING_TO_INLINE" )
29
30
inline fun <I , O > Flow<I>.pipe (transformer : FlowTransformer <I , O >) =
30
31
transformer.transform(this )
@@ -35,7 +36,6 @@ fun Context.toast(text: CharSequence) = Toast.makeText(this, text, Toast.LENGTH_
35
36
36
37
fun Fragment.toast (text : CharSequence ) = requireContext().toast(text)
37
38
38
- @OptIn(ExperimentalCoroutinesApi ::class )
39
39
@CheckResult
40
40
fun SwipeRefreshLayout.refreshes (): Flow <Unit > {
41
41
return callbackFlow {
@@ -44,7 +44,6 @@ fun SwipeRefreshLayout.refreshes(): Flow<Unit> {
44
44
}
45
45
}
46
46
47
- @OptIn(ExperimentalCoroutinesApi ::class )
48
47
@CheckResult
49
48
fun View.clicks (): Flow <View > {
50
49
return callbackFlow {
@@ -55,7 +54,7 @@ fun View.clicks(): Flow<View> {
55
54
56
55
data class RecyclerViewScrollEvent (val view : RecyclerView , val dx : Int , val dy : Int )
57
56
58
- @OptIn( ExperimentalCoroutinesApi :: class )
57
+ @CheckResult
59
58
fun RecyclerView.scrollEvents (): Flow <RecyclerViewScrollEvent > {
60
59
return callbackFlow {
61
60
val listener = object : RecyclerView .OnScrollListener () {
@@ -74,7 +73,7 @@ fun RecyclerView.scrollEvents(): Flow<RecyclerViewScrollEvent> {
74
73
}
75
74
}
76
75
77
- @OptIn( ExperimentalCoroutinesApi :: class )
76
+ @CheckResult
78
77
fun ViewGroup.detaches (): Flow <Unit > {
79
78
return callbackFlow {
80
79
val listener = object : View .OnAttachStateChangeListener {
0 commit comments