Skip to content

Commit

Permalink
fix data contract for the LazyReload strategy (#44)
Browse files Browse the repository at this point in the history
Co-authored-by: Artem Mochalov <artyom.mochalov@revolut.com>
  • Loading branch information
artyomychsvc and Artem Mochalov authored Nov 27, 2023
1 parent 1ab0073 commit 94e2187
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 13 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ And then to the module level `build.gradle.kts`:

```
dependencies {
implementation 'com.revolut.rxdata:dod:1.5.13'
implementation 'com.revolut.rxdata:core:1.5.13'
implementation 'com.revolut.rxdata:scheduler:1.5.13'
implementation 'com.revolut.rxdata:dod:1.5.14'
implementation 'com.revolut.rxdata:core:1.5.14'
implementation 'com.revolut.rxdata:scheduler:1.5.14'
}
```

Expand Down
2 changes: 1 addition & 1 deletion dfd/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
POM_ARTIFACT_ID=dfd
VERSION_NAME=1.5.13
VERSION_NAME=1.5.14
POM_NAME=dfd
POM_PACKAGING=jar
GROUP=com.revolut.flowdata
2 changes: 1 addition & 1 deletion dod-wrapper/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
POM_ARTIFACT_ID=dod-wrapper
VERSION_NAME=1.5.13
VERSION_NAME=1.5.14
POM_NAME=dod-wrapper
POM_PACKAGING=jar
GROUP=com.revolut.rxdata
2 changes: 1 addition & 1 deletion dod/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
POM_ARTIFACT_ID=dod
VERSION_NAME=1.5.13
VERSION_NAME=1.5.14
POM_NAME=dod
POM_PACKAGING=jar
GROUP=com.revolut.rxdata
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,17 @@ class DataObservableDelegate<Params : Any, Domain : Any> constructor(
} else {
sharedStorageRequest.getOrLoad(params)
.flatMapObservable { cached ->
val needToFetchFromNetwork = loadingStrategy.refreshStorage || cached.content == null
val cachedObservable = if (needToFetchFromNetwork) {
just(cached)
} else {
just(cached.copy(loading = false))
}
concat(
just(cached),
cachedObservable,
subject
).doAfterSubscribe {
if (loadingStrategy.refreshStorage || cached.content == null) {
if (needToFetchFromNetwork) {
fetchFromNetwork(cached.content, params)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ class DataObservableDelegateTest : BaseDataObservableDelegateTest() {
ioScheduler.triggerActions()

testObserver.assertValueCount(2)
testObserver.assertValueAt(1, Data(content = cachedDomain, error = null, loading = true))
testObserver.assertValueAt(1, Data(content = cachedDomain, error = null, loading = false))

ioScheduler.triggerActions()

Expand Down
2 changes: 1 addition & 1 deletion flow-extensions/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
POM_ARTIFACT_ID=extensions
VERSION_NAME=1.5.13
VERSION_NAME=1.5.14
POM_NAME=flow-core
POM_PACKAGING=jar
GROUP=com.revolut.flowdata
2 changes: 1 addition & 1 deletion model/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
POM_ARTIFACT_ID=model
VERSION_NAME=1.5.13
VERSION_NAME=1.5.14
POM_NAME=data
POM_PACKAGING=jar
GROUP=com.revolut.data
2 changes: 1 addition & 1 deletion rx-extensions/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
POM_ARTIFACT_ID=extensions
VERSION_NAME=1.5.13
VERSION_NAME=1.5.14
POM_NAME=core
POM_PACKAGING=jar
GROUP=com.revolut.rxdata
2 changes: 1 addition & 1 deletion scheduler/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
POM_ARTIFACT_ID=scheduler
VERSION_NAME=1.5.13
VERSION_NAME=1.5.14
POM_NAME=scheduler
POM_PACKAGING=aar
GROUP=com.revolut.rxdata

0 comments on commit 94e2187

Please sign in to comment.