-
Notifications
You must be signed in to change notification settings - Fork 211
Description
Describe the bug
In our application we have instances of the Store that use cache5 in the source of truth.
In some cases we need to invalidate the content of the store and we use store.clear(), but even if the cache is cleared (because deleteAll is invoked), no new values are emitted from the store.stream(..) ).
To Reproduce
Steps to reproduce the behavior:
Let's suppose we have a:
class Store5Cache:
Cache<MyKey, MyValue> by CacheBuilder<MyKey, MyValue>().build()
and the store:
internal class Store5Store(
store5Cache: Store5Cache,
myService: MyService
) : Store<MyKey, MyValue> by storeBuilderFromFetcherAndSourceOfTruth(
fetcher = Fetcher.of { myKey: MyKey ->
myService.getMyValue(myKey)
},
sourceOfTruth = SourceOfTruth.of(
nonFlowReader = { myKey -> store5Cache.getIfPresent(myKey) },
writer = { myKey, myValue -> store5Cache.put(myKey, myValue) },
delete = { myKey -> store5Cache.invalidate(myKey) },
deleteAll = { store5Cache.invalidateAll() },
)
).build()
and a collector
fun stateStream() = store5Store.stream(StoreReadRequest.cached(defaultKey, refresh = true))
.map {
when (it) {
is StoreReadResponse.Data -> it.dataOrNull()?.let { data -> Loaded(data) } ?: LoadedWithNoData
is StoreReadResponse.Error.Exception -> Error
is StoreReadResponse.Error.Message -> Error
is StoreReadResponse.Loading -> Loading
is StoreReadResponse.NoNewData -> NoNewData
}
}
After the emission of the first Loaded(data), if we call store5Store.clear() no values are emitted after the first.
Expected behavior
We expect that once the store is cleared, a new value will be fetched, but nothing happens.
Smartphone (please complete the following information):
- Store Version [5.0.0]
Additional context
Store5Test.zip
Metadata
Metadata
Assignees
Labels
Type
Projects
Status