code review notes
This commit is contained in:
parent
8ab4000b95
commit
7c012db927
|
|
@ -63,7 +63,7 @@ public final class PaginationDataLoadingModel<Cursor: ResettableRxDataSourceCurs
|
|||
state = .initial
|
||||
}
|
||||
|
||||
state = .loading(after: state)
|
||||
state = .initialLoading(after: state)
|
||||
case .next:
|
||||
if case .exhausted = state {
|
||||
fatalError("You shouldn't call load(.next) after got .exhausted state!")
|
||||
|
|
@ -76,7 +76,7 @@ public final class PaginationDataLoadingModel<Cursor: ResettableRxDataSourceCurs
|
|||
}
|
||||
|
||||
override func onGot(error: Error) {
|
||||
if case .exhausted? = error as? CursorError, case .loading(let after) = state {
|
||||
if case .exhausted? = error as? CursorError, case .initialLoading(let after) = state {
|
||||
switch after {
|
||||
case .initial, .empty: // cursor exhausted after creation
|
||||
state = .empty
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ final public class PaginationWrapper<Cursor: ResettableRxDataSourceCursor, Deleg
|
|||
|
||||
wrappedView.scrollView.isUserInteractionEnabled = true
|
||||
|
||||
if case .loading = afterState {
|
||||
if case .initialLoading = afterState {
|
||||
delegate?.paginationWrapper(didReload: newItems, using: cursor)
|
||||
|
||||
removeCurrentPlaceholderView()
|
||||
|
|
@ -166,7 +166,7 @@ final public class PaginationWrapper<Cursor: ResettableRxDataSourceCursor, Deleg
|
|||
}
|
||||
|
||||
private func onErrorState(error: Error, afterState: LoadingState) {
|
||||
if case .loading = afterState {
|
||||
if case .initialLoading = afterState {
|
||||
defer {
|
||||
wrappedView.scrollView.support.refreshControl?.endRefreshing()
|
||||
}
|
||||
|
|
@ -334,7 +334,7 @@ private extension PaginationWrapper {
|
|||
switch value {
|
||||
case .initial:
|
||||
base.onInitialState()
|
||||
case .loading(let after):
|
||||
case .initialLoading(let after):
|
||||
base.onLoadingState(afterState: after)
|
||||
case .loadingMore(let after):
|
||||
base.onLoadingMoreState(afterState: after)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ open class RxDataLoadingModel<DLS: DataLoadingState>: DataLoadingModel
|
|||
|
||||
private let stateVariable = Variable<LoadingStateType>(.initialState)
|
||||
var currentRequestDisposable: Disposable?
|
||||
let scheduler = SerialDispatchQueueScheduler(qos: .default)
|
||||
|
||||
var dataSource: DataSourceType
|
||||
let emptyResultChecker: EmptyResultChecker
|
||||
|
|
@ -64,7 +63,7 @@ open class RxDataLoadingModel<DLS: DataLoadingState>: DataLoadingModel
|
|||
state = .initialState
|
||||
}
|
||||
|
||||
state = .loadingState(after: state)
|
||||
state = .initialLoadingState(after: state)
|
||||
|
||||
requestResult(from: dataSource)
|
||||
}
|
||||
|
|
@ -89,7 +88,6 @@ open class RxDataLoadingModel<DLS: DataLoadingState>: DataLoadingModel
|
|||
func requestResult(from dataSource: DataSourceType) {
|
||||
currentRequestDisposable = dataSource
|
||||
.resultSingle()
|
||||
.observeOn(scheduler)
|
||||
.subscribe(onSuccess: { [weak self] result in
|
||||
self?.onGot(result: result, from: dataSource)
|
||||
}, onError: { [weak self] error in
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public enum GeneralDataLoadingState<DS: DataSource>: DataLoadingState {
|
|||
return .empty
|
||||
}
|
||||
|
||||
public static func loadingState(after: GeneralDataLoadingState<DS>) -> GeneralDataLoadingState<DS> {
|
||||
public static func initialLoadingState(after: GeneralDataLoadingState<DS>) -> GeneralDataLoadingState<DS> {
|
||||
return .loading
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
public indirect enum PaginationDataLoadingState<DS: DataSource>: DataLoadingState {
|
||||
|
||||
case initial
|
||||
case loading(after: PaginationDataLoadingState)
|
||||
case initialLoading(after: PaginationDataLoadingState)
|
||||
case loadingMore(after: PaginationDataLoadingState)
|
||||
case results(newItems: DS.ResultType, from: DS, after: PaginationDataLoadingState)
|
||||
case error(error: Error, after: PaginationDataLoadingState)
|
||||
|
|
@ -40,8 +40,8 @@ public indirect enum PaginationDataLoadingState<DS: DataSource>: DataLoadingStat
|
|||
return .empty
|
||||
}
|
||||
|
||||
public static func loadingState(after: PaginationDataLoadingState<DS>) -> PaginationDataLoadingState<DS> {
|
||||
return .loading(after: after)
|
||||
public static func initialLoadingState(after: PaginationDataLoadingState<DS>) -> PaginationDataLoadingState<DS> {
|
||||
return .initialLoading(after: after)
|
||||
}
|
||||
|
||||
public static func resultState(result: DS.ResultType,
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public protocol DataLoadingState {
|
|||
///
|
||||
/// - Parameter after: Previous state of data loading process.
|
||||
/// - Returns: Instance of loading state with given argument.
|
||||
static func loadingState(after: Self) -> Self
|
||||
static func initialLoadingState(after: Self) -> Self
|
||||
|
||||
/// Method that returns result state from a specific data source after a given state.
|
||||
///
|
||||
|
|
|
|||
Loading…
Reference in New Issue