add conformance to RxDataSource

This commit is contained in:
Ivan Smolin 2018-03-21 18:55:53 +03:00
parent 323300be63
commit 96a59c809e
4 changed files with 14 additions and 4 deletions

View File

@ -23,7 +23,9 @@
import RxSwift
/// Paging cursor implementation with enclosed cursor for fetching results
public class FixedPageCursor<Cursor: CursorType>: CursorType {
public class FixedPageCursor<Cursor: CursorType>: CursorType, RxDataSource {
public typealias ResultType = [Element]
fileprivate let cursor: Cursor
@ -76,6 +78,8 @@ public class FixedPageCursor<Cursor: CursorType>: CursorType {
/// FixedPageCursor subclass with implementation of ResettableType
public class ResettableFixedPageCursor<Cursor: ResettableCursorType>: FixedPageCursor<Cursor>, ResettableType {
public typealias ResultType = [Element]
public override init(cursor: Cursor, pageSize: Int) {
super.init(cursor: cursor, pageSize: pageSize)
}

View File

@ -45,7 +45,9 @@ public extension CursorType {
}
/// Map cursor implementation with enclosed cursor for fetching results
public class MapCursor<Cursor: CursorType, T>: CursorType {
public class MapCursor<Cursor: CursorType, T>: CursorType, RxDataSource {
public typealias ResultType = [Element]
public typealias Transform = (Cursor.Element) -> T?
@ -91,6 +93,8 @@ public class MapCursor<Cursor: CursorType, T>: CursorType {
/// MapCursor subclass with implementation of ResettableType
public class ResettableMapCursor<Cursor: ResettableCursorType, T>: MapCursor<Cursor, T>, ResettableType {
public typealias ResultType = [Cursor.Element]
public override init(cursor: Cursor, transform: @escaping Transform) {
super.init(cursor: cursor, transform: transform)
}

View File

@ -23,7 +23,9 @@
import RxSwift
/// Stub cursor implementation for array content type
public class StaticCursor<Element>: ResettableCursorType {
public class StaticCursor<Element>: ResettableRxDataSourceCursor {
public typealias ResultType = [Element]
private let content: [Element]

View File

@ -23,7 +23,7 @@
import RxSwift
import RxCocoa
public final class TotalCountCursor<CursorConfiguration: TotalCountCursorConfiguration>: ResettableCursorType {
public final class TotalCountCursor<CursorConfiguration: TotalCountCursorConfiguration>: ResettableRxDataSourceCursor {
public typealias Element = CursorConfiguration.ResultType.ElementType
public typealias ResultType = [Element]