Giter VIP home page Giter VIP logo

jetworking's People

Contributors

fredpi avatar jamitjona avatar jensk611 avatar mrylmz avatar raoulschwagmeier avatar simonnumbertwo avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jetworking's Issues

Handler API

Why are handlers not anonymous lambda implementation like DownloadHandler, DownloadExecutor, DownloadExecutorDelegate... ?

The API is clean but complicated is it possible to reduce the API requirements and complexity of executor stuff?

Encoder/Decoder Protocol

Data received or provided to an endpoint is currently decoded/encoded via the decoder property (encoder respectively). These properties are of type JSONDecoder/JSONEncoder. We should introduce protocols which abstract the decode / encode function that are used in the Client class. This what we would be more flexible what kind of object we want to decode/encode. This way it would be possible to work with objects other then JSON (e.g. XML)

DownloadHandler.CompletionHandler called twice

If a download via the download method in Client succeeds the completion handler is called twice:

The first call is triggered by downloadExecutor(_ downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL). The second by downloadExecutor(_ downloadTask: URLSessionDownloadTask, didCompleteWithError error: Error?) with error = nil.

Since download(url: URL, progressHandler: DownloadHandler.ProgressHandler, _ completion: @escaping DownloadHandler.CompletionHandler) offers a completion handler (and not some delegation), completion should only called once after the internal downloadTask has finished.

Add no internet connection handling

Description

As in some apps we need to have a no internet connection handling we should also embed this functionality into the framework. Idea would be to have a response interceptor which checks for the response error like (error as? URLError)?.code == URLError.Code.notConnectedToInternet and provide an error to the callee.

Also check out the NetworkReachabilityManager included in Alamofire for reference.

Executer vs Executor naming

Some classes and protocols are named Executer and some are named Executor we should define a single description and stick to it for API consistency

URLFactory could be reduced into Client

The URLFactory is a class overhead because it does only provide a single make method. Instead of defining that class it would make more sense to add a private extension to the Client.

Executor vs Executer as suffix

Both words are used in the current version. No one of them is wrong but this could make us be confused during implementation or debugging. I'd suggest to keep just one of them, not both.

Add a file caching mechanism

Description

When downloading files we shall add a caching mechanism so large files do not have to be requested multiple times.

CancellableRequest missleading naming

The public interface of the CancellableRequest only includes a cancel method and an identifier. It doesn't contain any informations about a request and is also only intended to be used for a request cancellation.

My suggestion is to rename the CancellableRequest into CancellationToken, RequestToken or define a proper interface to represent a non opaque request.

What is an Executor?

What is the exact purpose of an Executor and which other term could be used to make it more descriptive for users?

Provide the possibility to group requests

Description

In some cases we need to send multiple requests at the same time and only want to react when every response was successfully received and not have to check manually if all responses have been received and then react on it.

The idea behind this mechanism is to have a single function where to give multiple request having one callback where the result of all requests come at once.

Add middleware mechanism

Description

To be able to be highly flexible we shall add a mechanism where we provide such functionality like logging or setting headers by having a middleware component which has a process function which takes the request, manipulates it and finally returns it so other middleware components can process it further.

So for example when having a log middleware it will just log the request and return it.

These middleware components shall be exchangeable and extendable so when having the need to add a special handling one implements a middleware component conforming to the existing components and add it to the middleware stack.

Improve background download functionality

Description

The background download functionality has to be improved as well as documented so the programmer knows what to enable in the app to be able to do background downloads.

Furthermore it may be tested on other scenarios rather than just downloading a test file from a public server.

Improve error handling

Description

The current error handling must be improved. The defined APIError enum has to be taken into consideration and may be removed and improved by a better way of handling possible errors.

Add possibility to upload files

Description

The framework should provide a possibility to upload files.

Note

Only upload tasks from a file are supported. This basically means that you’ll have to upload from a file. Save the file locally first and start uploading from that file location. Uploads from data instances or a stream fail directly after the app exits.

Add default logging middleware component

Description

As logging is a vital part of the framework we need to provide a default logging middleware component which can be added to the middleware stack or may be added by default if the app is run in DEBUG mode or make it configurable if the middleware component is added or not.

Consider adding multiple log levels.

Incomplete Enumerations

The MultipartType and MultipartContentType enums seam to be incomplete and also is not extensible.

Instead of using an enum you could use a struct wrapper type with a String as raw value and provide named cases as static members in extensions. In this case a user would be able to define custom types.

Add possibility to add query parameters

Description

As some requests may use query parameters we should also embed an easy way to add those. Also keep in mind that the URL encoding is taken into consideration.

Fix completion handling on background thread

Description

While testing the framework within an app we noticed that the completion handler is called on a background thread which causes the an app crash. To prevent this we should move the completion handler calling to the main thread.

HTTPStatusCodeType issues

The HTTPStatusCodeType should not contain type as postfix because it is clear that it is a type, also it seams that it is incomplete yet please provide all possible status codes or just replace the type with an Int.

Provide a progress value when downloading files

Description

As sometimes files may be large and thus downloading them takes time we shall provide a progress to be able to display it to the user so he or she is aware of the long running task.

Client is leaking private API

The Client is leaking its private URLSession out in the initializer public init(configuration: Configuration, sessionConfiguration: ((inout URLSession) -> Void)? = nil) but stores it as a private member. Consider making the session public or remove the configurability from the initializer.

Add mechanism to send request synchronously

Description

In rare cases we need to send multiple requests but they need to be executed in a synchronous way so we need to provide an easy way to do it.

Maybe this can be done by using a queuing mechanism but we need to discuss this in more detail as soon as this ticket will be tackled.

Add Obj-C support

Add Obj-C support to help migrate legacy projects into modern APIs. It would be beneficial to support Obj-C so we would be able to migrate Obj-C based projects first into Obj-C with Jetworking and then from Obj-C Jetworking into Swift.

Provide the possibility to send fire and forget requests

Description

As not all requests require a response type, for example deleting an item, the framework should provide a possibility to send fire and forget calls.

Currently in the tests we use a VoidResponse being a Codable which in our opinion is not the best way of handling such case.

Removing redundant protocols

The Interceptor protocol is empty and is split into RequestInterceptor and ResponseInterceptor. My suggestion is to combine both API requirements into the Interceptor protocol and remove the other two protocols. An interceptor should be able to manage and manipulate the entire request response sequence. To avoid boilerplate code in user based application we could provide a default implementation or make the implementation of the methods optional.

Why do we use delegates?

It is also possible to use anonymous lambdas in Swift also with Obj-C support, why do we prefer to use delegates in a pure Swift Framework which doesn't depend on Apple Framework interfaces?

Improve Uploading functionality

Description

As currently background upload functionality is not working when switching within the tests to background execution we should tackle this as soon as possible.

Furthermore the multipart upload functionality should be tested more. The server I tested with was not sending any errors when having wrong multipart type or multipart content type.

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.