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.
- Host: GitHub
- URL: https://github.com/dbsystel/dbnetworkstack-sourcing
- Owner: dbsystel
- License: mit
- Created: 2016-12-12T08:07:53.000Z (over 8 years ago)
- Default Branch: develop
- Last Pushed: 2022-12-13T18:42:34.000Z (over 2 years ago)
- Last Synced: 2025-01-21T17:14:46.425Z (4 months ago)
- Topics: sourcing
- Language: Swift
- Homepage:
- Size: 451 KB
- Stars: 3
- Watchers: 7
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/dbsystel/DBNetworkStack-Sourcing)
[](https://github.com/Carthage/Carthage)
[](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 DBNetworkStackSourcinglet 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.