Skip to content

Commit 3015103

Browse files
committed
增加 launchAndRepeatWithViewLifecycle 重载函数
1 parent 7fecb79 commit 3015103

File tree

1 file changed

+14
-0
lines changed
  • baselib/src/main/kotlin/wsdydeni/library/android/utils/lifecycle

1 file changed

+14
-0
lines changed

baselib/src/main/kotlin/wsdydeni/library/android/utils/lifecycle/LifecycleExt.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ inline fun Fragment.launchAndRepeatWithViewLifecycle(
3636
}
3737
}
3838

39+
inline fun Fragment.launchAndRepeatWithViewLifecycle(
40+
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
41+
crossinline block: suspend CoroutineScope.() -> Unit
42+
) {
43+
launchAndRepeatWithViewLifecycle(Dispatchers.Main,minActiveState,block)
44+
}
45+
3946
/**
4047
* 更加简洁的语法封装
4148
*
@@ -61,4 +68,11 @@ inline fun FragmentActivity.launchAndRepeatWithViewLifecycle(
6168
block()
6269
}
6370
}
71+
}
72+
73+
inline fun FragmentActivity.launchAndRepeatWithViewLifecycle(
74+
minActiveState: Lifecycle.State = Lifecycle.State.STARTED,
75+
crossinline block: suspend CoroutineScope.() -> Unit
76+
) {
77+
launchAndRepeatWithViewLifecycle(Dispatchers.Main,minActiveState,block)
6478
}

0 commit comments

Comments
 (0)