AdapterInterface
causes code duplication problems.
#24
Labels
bug
Something isn't working
enhancement
New feature or request
medium priority
Issue has medium priority
Milestone
Problem begins from the, RequestHandler's reply function:
RequestHandler
's reply method was returning onlyDioAdapter
which caused chaining problems forDioInterceptor
, becauseDioInterceptor
itself needsDioInterceptor
to be returned fromreply
to chain methods and track theHistory
.So we needed to distinguish
returns
inside thereply
function, this problem was going to be solved with creating generic type parameter forRequestHandler
class, but while doing this another problem occurred: reply function was not able to understand what type it was returning(DioAdapter
orDioInterceptor
).For the above mentioned problem two ways of the solution were suggested to solve it.
First, define an abstract interface
AdapterInterface
for both, DioInterceptor and DioAdapter, also we need to define all the methods(onGet
,onPost
......) inside the interface and those methods will beoverriden
from mixinRequestRouted
.In this way reply function return type is
AdapterInterface
and also reply function maintains it's code completion ability when you are creating chains, But there is big problem of code management because interface defines all of the methods fromReqeustRouted
with their parameters , if we have to change parameters' types or quantities of all of the methods(onGet
,onPost
......) inside theRequestRouted
mixin we will have to change everything inside interface too.Second, reply functions return type will be T and it will return DioAdapter or DioInterceptor with following manner:
return DioAdapter() as T
orreturn DioInterceptor() as T
, In this case there is no need for separate interface but this type of solution destroyed auto completion ability forreply()
method while creating chains.For now, wile prioritizing auto completion, First method was left for use, But we are looking for other ways of solution and open to suggestions.
The text was updated successfully, but these errors were encountered: