Skip to content

Commit cb9013e

Browse files
committed
made livedata ref, but not mutable live data
1 parent 0669650 commit cb9013e

File tree

6 files changed

+31
-11
lines changed

6 files changed

+31
-11
lines changed

commandbasedarchitecture_coroutine/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ group = "io.scal"
2525
final def siteUrl = 'https://github.com/scalio/command-based-architecture'
2626
final def gitUrl = "https://github.com/scalio/command-based-architecture.git"
2727
// This is the library version used when deploying the artifact
28-
version = "0.4.3"
28+
version = "0.4.5"
2929

3030
final Properties properties = new Properties()
3131
properties.load(project.rootProject.file('local.properties').newDataInputStream())

commandbasedarchitecture_coroutine/src/main/java/io/scal/commandbasedarchitecture/broadcast/BaseBroadcastCommandViewModel.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import kotlinx.coroutines.Dispatchers
1717
import java.lang.ref.WeakReference
1818

1919
interface ChildViewModel<ChildState> {
20-
val fullDataState: MutableLiveData<ChildState>
20+
val fullDataState: LiveData<ChildState>
2121
}
2222

2323
/**
@@ -108,12 +108,22 @@ abstract class BaseBroadcastCommandViewModel<ChildKey, ChildState, ChildModel :
108108
if (hardViewModel)
109109
currentDataState.copy(
110110
hardViewStates = currentDataState.hardViewStates
111-
.plus(Pair(childKey, newViewModel.fullDataState))
111+
.plus(
112+
Pair(
113+
childKey,
114+
newViewModel.fullDataState as MutableLiveData<ChildState>
115+
)
116+
)
112117
)
113118
else
114119
currentDataState.copy(
115120
weakViewStates = currentDataState.weakViewStates
116-
.plus(Pair(childKey, WeakReference(newViewModel.fullDataState)))
121+
.plus(
122+
Pair(
123+
childKey,
124+
WeakReference(newViewModel.fullDataState as MutableLiveData<ChildState>)
125+
)
126+
)
117127
)
118128
mutableDataState.value = newDataState
119129

commandbasedarchitecture_rxjava/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ group = "io.scal"
2525
final def siteUrl = 'https://github.com/scalio/command-based-architecture'
2626
final def gitUrl = "https://github.com/scalio/command-based-architecture.git"
2727
// This is the library version used when deploying the artifact
28-
version = "0.4.3"
28+
version = "0.4.5"
2929

3030
final Properties properties = new Properties()
3131
properties.load(project.rootProject.file('local.properties').newDataInputStream())

commandbasedarchitecture_rxjava/src/main/java/io/scal/commandbasedarchitecture/broadcast/BaseBroadcastCommandViewModel.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import kotlinx.android.parcel.Parcelize
1717
import java.lang.ref.WeakReference
1818

1919
interface ChildViewModel<ChildState> {
20-
val fullDataState: MutableLiveData<ChildState>
20+
val fullDataState: LiveData<ChildState>
2121
}
2222

2323
/**
@@ -114,12 +114,22 @@ abstract class BaseBroadcastCommandViewModel<ChildKey, ChildState, ChildModel :
114114
if (hardViewModel)
115115
currentDataState.copy(
116116
hardViewStates = currentDataState.hardViewStates
117-
.plus(Pair(childKey, newViewModel.fullDataState))
117+
.plus(
118+
Pair(
119+
childKey,
120+
newViewModel.fullDataState as MutableLiveData<ChildState>
121+
)
122+
)
118123
)
119124
else
120125
currentDataState.copy(
121126
weakViewStates = currentDataState.weakViewStates
122-
.plus(Pair(childKey, WeakReference(newViewModel.fullDataState)))
127+
.plus(
128+
Pair(
129+
childKey,
130+
WeakReference(newViewModel.fullDataState as MutableLiveData<ChildState>)
131+
)
132+
)
123133
)
124134
mutableDataState.value = newDataState
125135

sample_coroutine/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ dependencies {
3838
implementation fileTree(dir: 'libs', include: ['*.jar'])
3939

4040
// implementation project(path: ':commandbasedarchitecture_coroutine')
41-
implementation 'io.scal:commandbasedarchitecture_coroutine:0.4.3'
41+
implementation 'io.scal:commandbasedarchitecture_coroutine:0.4.5'
4242

4343
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
4444

sample_coroutine/src/main/java/io/scal/commandbasedarchitecture/sample_coroutine/ui/viewmodel/ItemsChildBroadcastViewModel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package io.scal.commandbasedarchitecture.sample_coroutine.ui.viewmodel
22

33
import android.content.Context
44
import android.widget.Toast
5-
import androidx.lifecycle.MutableLiveData
5+
import androidx.lifecycle.LiveData
66
import io.scal.commandbasedarchitecture.CommandManager
77
import io.scal.commandbasedarchitecture.broadcast.ChildViewModel
88
import io.scal.commandbasedarchitecture.model.PageDataWithNextPageNumber
@@ -18,7 +18,7 @@ import kotlinx.coroutines.withContext
1818

1919
class ItemsChildBroadcastViewModel(
2020
private val key: ItemsBroadcastTypes,
21-
override val fullDataState: MutableLiveData<ListScreenState>,
21+
override val fullDataState: LiveData<ListScreenState>,
2222
val commandManager: CommandManager<ListScreenState>,
2323
private val context: Context
2424
) : ChildViewModel<ListScreenState> {

0 commit comments

Comments
 (0)