-
Notifications
You must be signed in to change notification settings - Fork 214
Support non exception errors from fetcher #123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
1c0da31
0075ada
2fe7b7e
9e3801e
d886e41
47463e6
7279bdf
cae8faa
cea6e71
2e1b012
7bd21db
44a5e15
03768e6
81548bb
3981d37
fb7c64d
738ed50
1527bec
cb50d9c
ed9d87f
cff04b4
3251fbb
5a2df2e
a0edfcf
e883e5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
| */ | ||
| package com.dropbox.android.external.store4.impl | ||
|
|
||
| import com.dropbox.android.external.store4.FetcherResult | ||
| import com.dropbox.android.external.store4.ResponseOrigin | ||
| import com.dropbox.android.external.store4.StoreResponse | ||
| import com.dropbox.flow.multicast.Multicaster | ||
|
|
@@ -45,7 +46,7 @@ internal class FetcherController<Key, Input, Output>( | |
| /** | ||
| * The function that provides the actualy fetcher flow when needed | ||
| */ | ||
| private val realFetcher: (Key) -> Flow<Input>, | ||
| private val realFetcher: (Key) -> Flow<FetcherResult<Input>>, | ||
| /** | ||
| * [SourceOfTruth] to send the data each time fetcher dispatches a value. Can be `null` if | ||
| * no [SourceOfTruth] is available. | ||
|
|
@@ -64,10 +65,16 @@ internal class FetcherController<Key, Input, Output>( | |
| scope = scope, | ||
| bufferSize = 0, | ||
| source = flow { emitAll(realFetcher(key)) }.map { | ||
| StoreResponse.Data( | ||
| it, | ||
| origin = ResponseOrigin.Fetcher | ||
| ) as StoreResponse<Input> | ||
| when (it) { | ||
| is FetcherResult.Data -> StoreResponse.Data( | ||
| it.value, | ||
| origin = ResponseOrigin.Fetcher | ||
| ) as StoreResponse<Input> | ||
| is FetcherResult.Error -> StoreResponse.Error( | ||
| it.error, | ||
| origin = ResponseOrigin.Fetcher | ||
| ) | ||
| } | ||
| }.catch { | ||
|
||
| emit(StoreResponse.Error(it, origin = ResponseOrigin.Fetcher)) | ||
| }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would store response work here? Or is it too generic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Store response has an origin, which I don't want to let users override.