@@ -8,17 +8,6 @@ fun LiveData<Boolean>.observeAsAction(
88 action : () -> Unit ,
99 onActionResolved : () -> Unit
1010) {
11- // LiveData will only keep one subscription per-LifecycleOwner. If one is already present the
12- // new LiveData.observe() call will have no effect. See implementation of LiveData.observe() for
13- // reference. If action relies on variable parameters subsequent calls would be ignored and the
14- // old set of parameters will be used.
15- //
16- // The most common example is action using a CoroutineScope provided by a Composable. The
17- // CoroutineScope can change if the Composable is recreated (not just recomposed). By default
18- // the old scope would be used instead of the new one.
19- //
20- // To resolve this problem we remove previous observers on the provided LifecycleOwner is
21- // BEFORE calling LiveData.observe() to ensure a new subscription with new parameters.
2211 this .removeObservers(lifecycleOwner)
2312 this .observe(lifecycleOwner) { isActionRequested ->
2413 if (isActionRequested == true ) {
@@ -33,17 +22,6 @@ fun <T> LiveData<T?>.observeAsAction(
3322 action : (T ) -> Unit ,
3423 onActionResolved : () -> Unit
3524) {
36- // LiveData will only keep one subscription per-LifecycleOwner. If one is already present the
37- // new LiveData.observe() call will have no effect. See implementation of LiveData.observe() for
38- // reference. If action relies on variable parameters subsequent calls would be ignored and the
39- // old set of parameters will be used.
40- //
41- // The most common example is action using a CoroutineScope provided by a Composable. The
42- // CoroutineScope can change if the Composable is recreated (not just recomposed). By default
43- // the old scope would be used instead of the new one.
44- //
45- // To resolve this problem we remove previous observers on the provided LifecycleOwner is
46- // BEFORE calling LiveData.observe() to ensure a new subscription with new parameters.
4725 this .removeObservers(lifecycleOwner)
4826 this .observe(lifecycleOwner) { actionParams ->
4927 if (actionParams != null ) {
0 commit comments