An open API service indexing awesome lists of open source software.

https://github.com/dbsystel/dbnetworkstack-sourcing

Combines DBNetworkStack and Sourcing by providing a network resource backed data provider.
https://github.com/dbsystel/dbnetworkstack-sourcing

sourcing

Last synced: 2 months ago
JSON representation

Combines DBNetworkStack and Sourcing by providing a network resource backed data provider.

Awesome Lists containing this project

README

        

[![Build Status](https://travis-ci.org/dbsystel/DBNetworkStack-Sourcing.svg?branch=develop)](https://travis-ci.org/dbsystel/DBNetworkStack-Sourcing)
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![codecov](https://codecov.io/gh/dbsystel/DBNetworkStack-Sourcing/branch/develop/graph/badge.svg)](https://codecov.io/gh/dbsystel/DBNetworkStack-Sourcing)

# DBNetworkStack-Sourcing

This component acts as a bridge between [Sourcing](https://github.com/lightsprint09/Sourcing) and [DBNetworkStack](https://github.com/dbsystel/DBNetworkStack). It is a data provider, for resources fetched by a network service.

## Usage
```swift
import Sourcing
import DBNetworkStack
import DBNetworkStackSourcing

let networkService: NetworkService = //
let resource: Resource<[Int]> = //

let resourceDataProvider = ResourceDataProvider(resource: resource, networkService: networkService)

// Start loading content
resourceDataProvider.load()
```

### Access state of the loading operation
You can either set a delegate and get notified when state changes or you could access `ressourceDataProvider.state`.

```swift
let delegate: ResourceDataProviderDelegate = //
let resourceDataProvider = ResourceDataProvider(resource: resource, networkService: networkService)

// Set delegate to get notified about state changes.
resourceDataProvider.delegate = delegate

// Access the current state.
resourceDataProvider.state
```

### Reloading a resource
```swift
let newResource: Resource<[Int]> = //
resourceDataProvider.reconfigure(with: newResource)
resourceDataProvider.load()
```

Somtimes it can be handy to skip the state of loading (e.g when inital loading displays a spinner and following reloads should not)
```swift
let newResource: Resource<[Int]> = //
resourceDataProvider.reconfigure(with: newResource)
resourceDataProvider.load(skipLoadingState: true)
```
**skipLoadingState is availaibe in initial `load()` as well**

### Accessing current content
```swift
resourceDataProvider.content
```

## Requirements
- iOS 9.0+
- Xcode 9.0+
- Swift 4.0

## Installation

### Carthage

[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

Specify the following in your `Cartfile`:

```ogdl
github "dbsystel/DBNetworkStack-Sourcing" ~> 1.0
```
## Contributing
Feel free to submit a pull request with new features, improvements on tests or documentation and bug fixes. Keep in mind that we welcome code that is well tested and documented.

## Contact
Lukas Schmidt ([Mail](mailto:[email protected]), [@lightsprint09](https://twitter.com/lightsprint09)),
Christian Himmelsbach ([Mail](mailto:[email protected]))

## License
DBNetworkStack-Sourcing is released under the MIT license. See LICENSE for details.