dbsystel / DBNetworkStack-Sourcing

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status Carthage Compatible codecov

DBNetworkStack-Sourcing

This component acts as a bridge between Sourcing and DBNetworkStack. It is a data provider, for resources fetched by a network service.

Usage

import Sourcing
import DBNetworkStack
import DBNetworkStackSourcing

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

let resourceDataProvider = ResourceDataProvider<Int>(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.

let delegate: ResourceDataProviderDelegate = //
let resourceDataProvider = ResourceDataProvider<Int>(resource: resource, networkService: networkService)

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

// Access the current state.
resourceDataProvider.state

Reloading a resource

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)

let newResource: Resource<[Int]> = //
resourceDataProvider.reconfigure(with: newResource)
resourceDataProvider.load(skipLoadingState: true)

skipLoadingState is availaibe in initial load() as well

Accessing current content

resourceDataProvider.content

Requirements

  • iOS 9.0+
  • Xcode 9.0+
  • Swift 4.0

Installation

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

Specify the following in your Cartfile:

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, @lightsprint09), Christian Himmelsbach (Mail)

License

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

About

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

License:MIT License


Languages

Language:Swift 97.2%Language:Objective-C 2.8%