Giter Site home page Giter Site logo

V5.0 about networkresponseadapter HOT 6 CLOSED

haroldadmin avatar haroldadmin commented on May 21, 2024
V5.0

from networkresponseadapter.

Comments (6)

haroldadmin avatar haroldadmin commented on May 21, 2024 2

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.

haroldadmin avatar haroldadmin commented on May 21, 2024 1

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.

gilgoldzweig avatar gilgoldzweig commented on May 21, 2024

from networkresponseadapter.

argenkiwi avatar argenkiwi commented on May 21, 2024

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.

haroldadmin avatar haroldadmin commented on May 21, 2024

@argenkiwi #36

from networkresponseadapter.

argenkiwi avatar argenkiwi commented on May 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.