Comments (6)
The workaround for now would be to use the coroutines-rxjava interop library
interface PandaApi {
@GET("/")
suspend fun getPandas(): ApiResult<Pandas, Nothing>
}
// Use rxSingle
rxSingle { pandaApi.getPandas() }
.subscribe { result -> ... }
from eithernet.
Oh interesting, so right now, if we wanted to use ApiResult<T, E>
we can't use RxJava right away. Our best bet for async calls for a codebase that uses Rx would be to use coroutines adapter and then interop with Rxjava in order to work with existing Rx chains?
from eithernet.
Yup seems so. In principle it works but in testing it seems this is a java limitation
from eithernet.
I have an idea for this: we could use Retrofit's @Tag
annotation to receive a custom ResultHint
that in turn holds a ResultType
instance. We can then look for this hint and use it as an override.
@GET("/")
fun anRxEndpoint(@Tag resultHint: ResultHint): Single<ApiResult<SuccessType, FailureType>>
It's annoyingly not type-safe though, but we could maybe we could encourage something like this
@GET("/")
fun anRxEndpoint(@Tag resultHint: ResultHint = ResultHint.create<SuccessType, FailureType>()): Single<ApiResult<SuccessType, FailureType>>
So then callers don't have to implement it themselves
from eithernet.
Another, possibly better alternative would be to see if we can read the full generic type from metadata annotations on the class. We'd have to step out of retrofit's standard API and incur the metadata parsing cost, but we could make it opt-in maybe?
from eithernet.
I'm going to close this as infeasible for now
from eithernet.
Related Issues (20)
- Embed proguard rules? HOT 2
- [BUG]
- KotlinNullPointerException when api call returns 204 No Content with null response HOT 4
- [BUG] EitherNet + MultiDex + minSDK 19 HOT 1
- Unable to create converter for class com.slack.eithernet.ApiResult when using Nothing with Moshi HOT 10
- Integrate Kotlin ABI validator
- ClassCastException in ApiResultConverterFactory when minify is enabled
- Automatic snapshot publishing always skipped HOT 1
- [BUG] test fixtures do not seem to be published HOT 3
- enqueueFromJava does not handle inherited functions in lookups
- Consider making a recipes/samples subproject
- [BUG] Exception when looking for an annotation that doesn't exist HOT 1
- [FEATURE] Support declarative error model binding HOT 2
- [BUG] v1.3.0 published with invalid Gradle Module Metadata HOT 2
- (how) should we handle error bodies in 4xx responses? HOT 3
- Api<Unit, Throwable> crashes with NPE when http code is 204 or 205 HOT 3
- Retrofit converter for wrapped responses
- Add an escape hatch to retries
- Improve 204 (No content) handling and polymorphism
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eithernet.