Comments (6)
I've been working on v5.0 for the past couple of weekends. I might be able to provide you with an update before the holiday season starts, but no promises :)
from networkresponseadapter.
Thank you for creating this issue. We'll use it as the place to plan new features for a v5.0 release.
Switch to sealed interfaces
Kotlin 1.5 brings sealed interfaces support. Using NetworkResponse
with sealed interfaces would allow greater flexibility in dividing the Success
and Error
types. The current Error
interface in the library is not meant to be extended, but client applications are free to do so. Sealed interfaces would eliminate this possibility.
Move away from nested sub-classes
Moving the sub classes of NetworkResponse
to top level classes would reduce verbosity when checking their types in a when
expression:
sealed interface NetworkResponse<S, E>
data class Success<S, E>(val data: S?) : NetworkResponse<S, E>
sealed interface Error<S, E> : NetworkResponse<S, E>
data class ServerError<S, E>(val error: E?) : Error<S, E>
data class NetworkError<S, E>(val error: E?) : Error<S, E>
data class UnknownError<S, E>(val error: E?) : Error<S, E>
when (response) {
is Success ->
is NetworkError ->
is ServerError ->
is UnknownError ->
}
Improve generic parameter handling
Some sub-types of NetworkResponse
utilize Nothing
as a generic type parameter, which is semantically unsound. Nothing
is reserved for extra-ordinary situations that are never meant to happen, such as exceptions. Similarly, the case of empty server bodies is handled with Unit
. v5.0 should make improvements to this API.
I'll update this issue as we progress towards 5.0. Any other feature requests or bug reports are very welcome.
from networkresponseadapter.
from networkresponseadapter.
I've also raised an issue related to 204 responses, which are success response which have no body. I noticed we check if the body is not null to determine whether we have a success or a server error response. Maybe we need another success representation without a body, which hopefully could be solved with sealed interfaces as well.
from networkresponseadapter.
from networkresponseadapter.
Looking forward to the v5 release. When Kotlin 1.7 enforces exhaustive when statements, the sealed interfaces change will make a nice difference.
from networkresponseadapter.
Related Issues (20)
- NetworkResponse Error Managing HOT 3
- Success code 204 (no content) returns server error HOT 1
- NetworkResponseAdapterFactory crashes on unhandled response types HOT 1
- ResponseHandler should allow to pass our own converter HOT 5
- moshi exception incorrectly classified as network error HOT 2
- NetworkResponse.UnknownError HOT 2
- How to handle responses with 200 **AND** 204 (No Content) HOT 3
- How To Handle Error Response ? HOT 4
- When expression with Success and Error is not exhaustive HOT 4
- Error when app is builded in release mode HOT 2
- Retrofit mock HOT 2
- How to run this source code in Android Studio??? HOT 8
- Are there any projects that have used this library? (open source) HOT 4
- Binaries not available on Maven Central HOT 4
- 5.0.0 is not backwards compatible HOT 2
- Adding NetworkResponseAdapterFactory to your Retrofit client in Java HOT 3
- Excpetion: Unable to create call adapter when I try to use with Retrofit and Moshi HOT 1
- Application crashing when minifyEnabled is set to true HOT 3
- How to use async Call?
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 networkresponseadapter.