ABSDKArrayDataSource
public class ABSDKArrayDataSource<Operation, Data> : ABSDKDataSource
A data source that binds with an array type of data in a GraphQL operation and monitors its update
-
Init an array data source
Declaration
Swift
public init(client: ABSDKClient, operation: Operation, dataSourceMapper: @escaping ArrayDataSourceMapper<Operation, Data>, dataSourceUpdateHandler: @escaping DataSourceUpdateHandler, arrayDataKeyEqualChecker: ArrayDataKeyEqualChecker<Data>? = nil)
Parameters
client
an ABSDKClient for sending requests
operation
A GraphQL operation to get the array
dataSourceMapper
A callback to extract the concerned array from the operation result
dataSourceUpdateHandler
A callback that gets called whenever the concerned array gets update
arrayDataKeyEqualCHecker
An optional callback to check whether two elements in the concerned array are with the same key. This is used to calculate the row changes to update view dynamically.
-
Get number of sections in the array, for tableView/CollectionView. default is 1
Declaration
Swift
public func numberOfSections() -> Int
-
Get number of rows in the array, for tableView/CollectionView.
Declaration
Swift
public func numberOfRows(section: Int) -> Int
-
Get the element in the array, for tableView/CollectionView.
Declaration
Swift
public func itemForIndexPath(indexPath: IndexPath) -> Data?
Parameters
indexPath
The indexPath of the item
Return Value
The element at the indexPath
-
Get row changes, usually get called in DataSourceUpdateHandler
Declaration
Swift
public func getChanges() -> [RowChange]
-
Start observing on the operation related data
Declaration
Swift
public func observe()
-
Start observing on the operation related data
Declaration
Swift
public func observe() -> <Operation, Data> (ABSDKArrayDataSource<Operation, Data>) -> () -> ()