Skip to content

Commit

Permalink
Merge pull request #52 from dbsystel/release/0.6.0
Browse files Browse the repository at this point in the history
Release 0.6.0 💈
  • Loading branch information
lightsprint09 authored Aug 2, 2017
2 parents 0d18f5b + eff8566 commit 4bd5302
Showing 1 changed file with 2 additions and 28 deletions.
30 changes: 2 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,38 +74,13 @@ networkService.request(resource, onCompletion: { origin in
})
```

## Extendability
The following example outlines how to extend DBNetworkStack to support XML response models:

```swift
protocol XMLMappable {
init(object: Dictionary<String, AnyObject>) throws
}

struct XMLResource<T : XMLMappable> : ResourceModeling {
let request: NetworkRequestRepresening

init(request: NetworkRequestRepresening) {
self.request = request
}

var parse: (data: NSData) throws -> T {
return { data in
let xmlObject = // Your data to xml object conversion
try! T(object: xmlObject) as T
}
}
}
```
```XMLMappable``` defines the protocol, response model objects must conform to. The model class conforming to this protocol is responsible to convert a generic representation of the model into it’s specialized form.
```XMLResource<T : XMLMappable>``` defines a resource based on a given ```XMLMappable``` model. The parse function is responsible of converting raw response data to a generic representation.

## Accessing HTTPResponse

Request your resource and handle the result & response. This is similar to just requesting a resulting model.
```swift
networkService.request(resource, onCompletionWithResponse: { htmlText, response in
print(htmlText)
print(response)
}, onError: { error in
//Handle errors
})
Expand All @@ -122,7 +97,6 @@ The following table shows all the protocols and their default implementations.
| ```NetworkServiceProviding``` | ```NetworkService``` |
| ```NetworkRequestRepresenting``` | ```NetworkRequest``` |
| ```NetworkTaskRepresenting``` | ```URLSessionTask``` |
| ```ResourceModelling``` | ```Resource<Model>``` |

## Composable Features

Expand All @@ -146,7 +120,7 @@ The following table shows all the protocols and their default implementations.
Specify the following in your `Cartfile`:

```ogdl
github "dbsystel/dbnetworkstack" ~> 0.5
github "dbsystel/dbnetworkstack" ~> 0.6
```

### CocoaPods
Expand Down

0 comments on commit 4bd5302

Please sign in to comment.