Coder Social home page Coder Social logo

dbnetworkstack's People

Contributors

ch-one avatar dennispost avatar lightsprint09 avatar oliverdobner-dbsystel avatar philippseibel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dbnetworkstack's Issues

Rework NetworkRequestRepresenting

Issue:

For the following reasons, we want to try an other approach to represent requests:

  • Base URL Key concept is not directly comprehensible
  • Not all information about the request is available: NetworkRequestRepresenting does not contain the whole URL to perform the request.
  • NetworkRequestRepresenting can be configured to be invalid. This is not ideal.

Proposed solution:

We aim for a solution that addresses these points. The proposed solution is to rewrite the NetworkRequestRepresenting protocol that its only function is to return a valid URLRequest.

  • Simplifies usage of DBNetworkStack by removing Base URL Key concept (See: #9). An URLRequest contains all information about the request
  • With an URLRequest starting this request should always be possible, which resolves #31 and #32

NetworkServiceMock where responses can be defined before they are consumed

In some situations it would be helpful to have a NetworkServiceMock where mocked responses can be defined before they are consumed.

Having an additional mock would bring the following benefits:

  • Separation of mock setup and test code
  • Response definition can be located in one place (in the beginning of the test method or in setUp method) and is not scattered
  • Cases where it is not clear, when the network call will happen are no longer a problem
  • Freedom of choice: Current NetworkServiceMock is still available

In addition the possibility to define a timing behaviour may be interesting. Something like:

  • Immediately
  • Delayed (by amount of time)

PullRequest Template

Create a PullRequest Template containing:

  • UnitTests
  • Code documentation
  • Readme Documentation
  • API breaking changes

Error when building with Carthage

When building DBNetworkStack with Carthage I get the following errors.

Done linting! Found 0 violations, 0 serious in 41 files.
swiftlint(8910,0x7000075e5000) malloc: *** error for object 0x7000075e2150: Non-aligned pointer being freed (2)
*** set a breakpoint in malloc_error_break to debug
/Users/dennis/Library/Caches/org.carthage.CarthageKit/DerivedData/9.4_9Q1019a/DBNetworkStack/1.1/Build/Intermediates.noindex/ArchiveIntermediates/DBNetworkStack/IntermediateBuildFilesPath/DBNetworkStack.build/Release-iphoneos/DBNetworkStack.build/Script-C60F0D0D1D9A76B90028C417.sh: line 6:  8910 Abort trap: 6           swiftlint
Command /bin/sh failed with exit code 134

** ARCHIVE FAILED **


The following build commands failed:
	PhaseScriptExecution ๐Ÿšง\ Swift\ Lint /Users/dennis/Library/Caches/org.carthage.CarthageKit/DerivedData/9.4_9Q1019a/DBNetworkStack/1.1/Build/Intermediates.noindex/ArchiveIntermediates/DBNetworkStack/IntermediateBuildFilesPath/DBNetworkStack.build/Release-iphoneos/DBNetworkStack.build/Script-C60F0D0D1D9A76B90028C417.sh
(1 failure)

My current solution is to remove the SwiftLint build phase.

Travis randomly fails

Error:

Signing /Users/travis/Library/Developer/Xcode/DerivedData/DBNetworkStack-gkizlcawqmitiocnuhdyinfispui/Build/Products/Debug-appletvsimulator/DBNetworkStackTests.xctest
** TEST FAILED **

The command "set -o pipefail && xcodebuild -scheme DBNetworkStack -destination "$DESTINATION" $ACTION $SIGN | xcpretty" exited with 65.```

Gracefull handling mocked response without request

The methods returnSuccess and returnError of NetworkServiceMock should handle an empty callbacks stack gracefull. This means, when no request has been triggered, a return should not result in a crash.

Methods:

public func returnError(with error: NetworkError) {

public func returnSuccess<T>(with serializedResponse: T, httpResponse: HTTPURLResponse = HTTPURLResponse()) {

Empty Path

When starting a request with an empty path, a fatal error is thrown.
An empty path should be valid.

Change Travis config

TravisCI should only run in one single container. This should decrease build times

Failing Request

In cases where starting a request is not possible (e.g. base url for BaseUrlKey is missing), requests must be able to fail.

One way would be to have an optional network task as return type.

Extend NetworkServiceProviding to support multiple requests

something like this, but more solid:

extension NetworkServiceProviding {
    public func requestMulti<T, Result>(_ resources: [Resource<T>], mapToResult: @escaping ([T]) -> Result,
                                    onCompletion: @escaping (Result) -> Void, onError: @escaping (NetworkError) -> Void) {
        var results: [T?] = resources.map { _ in nil }
        resources.enumerated().forEach({ i, resource in
            request(resource, onCompletion: { result in
                results[i] = result
                let finalResult = results.flatMap { $0 }
                if finalResult.count == resources.count {
                    onCompletion(mapToResult(finalResult))
                }
            }, onError: { err in
                onError(err)
            })
        })
    }
}

An example for a POST request would be nice

I was looking for an example to a POST request but couldn't find it in the readme.
And do I also expect a Resource after the POST when my Server is just answering with a 200 ok?

Async request modyfing

In Addition to modify request in sync before executing, it is helpful to be able to do this async as well.

Prevent SwiftLint from failing future builds

if [ \"${CONFIGURATION}\" != \"Release\" ]; then\nif which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\nfi\n could fix this

@ahersch

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.