The markdown parsing is broken/disabled for release notes. Sorry about that, I'm chasing the source of a crash that's been bringing this website down for the last couple of days.
Minor fix.
**Full Changelog**: https://github.com/KazaKago/StoreFlowable.swift/compare/4.0.0...4.1.0
## Breaking Changed
* Migrate to async/await by Swift Concurrency from Combine framework.
* Set up StoreFlowable more easily than before.
See the README Basic Usage for details.
**Full Changelog**: https://github.com/KazaKago/StoreFlowable.swift/compare/3.2.0...4.0.0
## Bugfix Release
## Breaking Changes
- No need to `key` variable in `StoreFlowableFactory` class.
- Need to add parameter in `StoreFlowableFactory` class methods.
Before
```swift
struct UserFlowableFactory : StoreFlowableFactory {
typealias KEY = UserId
typealias DATA = UserData
init(userId: UserId) {
key = userId
}
let key: UserId
func loadDataFromCache() -> AnyPublisher<UserData?, Never> {
userCache.load(userId: key)
}
...
}
let userFlowable = UserFlowableFactory(userId: UserId(100)).create()
userFlowable.publish()
```
After
```swift
struct UserFlowableFactory : StoreFlowableFactory {
typealias PARAM = UserId
typealias DATA = UserData
func loadDataFromCache(param: UserId) -> AnyPublisher<UserData?, Never> {
userCache.load(userId: param)
}
...
}
let userFlowable = UserFlowableFactory().create(UserId(100))
userFlowable.publish()
```
## New Feature
- Two-way pagination.
- Use TwoWayPaginationStoreFlowable & TwoWayPaginationStoreFlowableFactory.
- You can now hold the key in this library to use for the next fetch of pagination.
- Please pass nextKey and prevKey in the return value of fetch method.
- If you pass null or an empty string, it is considered that there is no additional data.
```swift
struct MyFlowableFactory : PaginationStoreFlowableFactory {
...
func fetchNextDataFromOrigin(nextKey: String) -> AnyPublisher<Fetched<[DATA]>, Error> {
githubApi.getRepos(nextPageToken: nextKey).map { data in
Fetched(data: data, nextKey: data.nextPageToken)
}.eraseToAnyPublisher()
}
}
```
## Breaking Changes
- Rename LoadingState from State.
- Rename PaginationStoreFlowable from PaginatingStoreFlowable.
- Changed the method to be implemented in StoreFlowableFactory.
- Removed methods that were deprecated in 1.x.
## Behavior Changes
- LoadingState always returns Completed on additional loads.
- Instead, refer to the Completed parameters `next`,` prev` to determine the status of additional loads.
```swift
flowable.publish()
.receive(on: DispatchQueue.main)
.sink { state in
state.doAction(
onLoading: { (contents: [DATA]?) in
// Whole (Initial) data loading.
},
onCompleted: { (contents: [DATA], next: AdditionalLoadingState, _) in
// Whole (Initial) data loading completed.
next.doAction(
onFixed: { (canRequestAdditionalData: Bool) in
// No additional processing.
},
onLoading: {
// Additional data loading.
},
onError: { (error: Error) in
// Additional loading error.
}
)
},
onError: { (error: Error) in
// Whole (Initial) data loading error.
}
)
}
```
[Deprecated] Use `StoreFlowableFactory` instead `StoreFlowableCallback`.
[Deprecated] Rename `GettingFrom` enum parameters.
Initial release.