This Swift library lets you connect an API call (or any other datasource) to the view layer within minutes. It has a ready-to-go UITableViewDatasource
and UICollectionViewDatasource
along with matching ViewControllers and is built in a way that datasources for other view types (e.g. UIStackView
) can be easily composed.
An idiomatic tableview that displays data from an API call and supports:
- pull-to-refresh,
- on-disk-caching,
- clear-view-on-logout,
- a loading indicator if no cached data is shown (e.g. on first app start),
- displaying "no results" in a dedicated cell if there aren't any,
- displaying errors in a dedicated cell
can be setup with ~100 lines of configuration (see Example).
The best way to use this library is to create a Datasource
, and connect it to one or more
Table/CollectionViewControllers by using the builder pattern provided by ListViewDatasourceConfiguration
.
Features, like showing errors as items/cells, are added in this configuration before creating the actual Table/CollectionViewController.
You can subscribe to changes in the Datasource
e.g. for stopping the Pull to Refresh indicator after loading is done.
DataSourcerer can be viewed as two parts:
- A very basic FRP framework
- View adapters that subscribe to the FRP framework's structures to do work, like refreshing subviews. The adapters are split into many structs and classes, but Builder patterns added at the crucial points should provide good usability for the most common usage scenarios.
You may ask, who needs another FRP framework, why reinvent the wheel? There are various reasons this project has its own FRP configuration:
- Reducing references to projects that are not under our control
- Keeping development cadence (e.g. with new Swift releases) independent of other projects
- Avoid binding Datasourcerer users to a specific ReactiveSwift/RxSwift/ReactiveKit/... version (especially annoying for Cocoapods users)
- The self-built approach seems to be easier to debug, because it has way less levels of abstraction due to the reduced feature set.
Yes. More tests are expected to be added within Q1 2019. The goal is to reach 100% coverage eventually.
To run the example project, clone the repo, and run pod install
from the Example directory first.
DataSourcerer will soon be available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'DataSourcerer'
Q1 2019:
- Add seamless interaction with various Rx libraries
- Add missing IdiomaticSectionedTableViewDatasource
- Up test coverage to 100%
Later, but ASAP:
- AloeStackView support
Manuel Maly, manuel@creativepragmatics.com
DataSourcerer is available under the MIT license. See the LICENSE file for more info.