Skip to content

Commit f944c33

Browse files
Merge pull request #31 from bijaykumarpun/fix/cleanups
Fix/cleanups: Minor cleanups
2 parents 9a7cfc0 + 1c58e4c commit f944c33

File tree

2 files changed

+4
-22
lines changed

2 files changed

+4
-22
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ local.properties
77

88
# Log/OS Files
99
*.log
10+
app/.DS_Store
1011

1112
# Android Studio generated files and folders
1213
captures/
@@ -31,3 +32,6 @@ google-services.json
3132

3233
# Android Profiling
3334
*.hprof
35+
36+
# Release
37+
app/release/*

app/src/main/java/global/x/weather/infrastructure/util/LiveDataExtension.kt

-22
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)