This component acts as a bridge between Sourcing and DBNetworkStack. It is a data provider, for resources fetched by a network service.
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()
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
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
resourceDataProvider.content
- iOS 9.0+
- Xcode 9.0+
- Swift 4.0
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
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.
Lukas Schmidt (Mail, @lightsprint09), Christian Himmelsbach (Mail)
DBNetworkStack-Sourcing is released under the MIT license. See LICENSE for details.