@@ -8,17 +8,6 @@ fun LiveData<Boolean>.observeAsAction(
8
8
action : () -> Unit ,
9
9
onActionResolved : () -> Unit
10
10
) {
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.
22
11
this .removeObservers(lifecycleOwner)
23
12
this .observe(lifecycleOwner) { isActionRequested ->
24
13
if (isActionRequested == true ) {
@@ -33,17 +22,6 @@ fun <T> LiveData<T?>.observeAsAction(
33
22
action : (T ) -> Unit ,
34
23
onActionResolved : () -> Unit
35
24
) {
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.
47
25
this .removeObservers(lifecycleOwner)
48
26
this .observe(lifecycleOwner) { actionParams ->
49
27
if (actionParams != null ) {
0 commit comments