CKCollectionViewTransactionalDataSource Class Reference

Inherits from NSObject
Declared in CKCollectionViewTransactionalDataSource.h

Overview

This class is an implementation of a UICollectionViewDataSource that can be used along with components. For each set of changes (i.e insertion/deletion/update of items and/or insertion/deletion of sections) the datasource will compute asynchronously on a background thread the corresponding component trees and then apply the corresponding UI changes to the collection view leveraging automatic view reuse.

Doing so this reverses the traditional approach for a UICollectionViewDataSource. Usually the controller layer will tell the UICollectionView to update and then the UICollectionView ask the datasource for the data. Here the model is more Reactive, from an external prospective, the datasource is told what changes to apply and then tell the collection view to apply the corresponding changes.

– initWithCollectionView:supplementaryViewDataSource:configuration:

The collectionView is held strongly and its datasource property will be set to the receiver.

- (instancetype)initWithCollectionView:(UICollectionView *)collectionView supplementaryViewDataSource:(id<CKSupplementaryViewDataSource>)supplementaryViewDataSource configuration:(CKTransactionalComponentDataSourceConfiguration *)configuration

Parameters

collectionView

The collectionView is held strongly and its datasource property will be set to the receiver.

supplementaryViewDataSource

@see the supplementaryViewDataSource property. Will be held weakly, pass nil if you don’t need supplementary views.

Declared In

CKCollectionViewTransactionalDataSource.h

– applyChangeset:mode:userInfo:

Applies a changeset either synchronously or asynchronously to the collection view. If a synchronous changeset is applied while asynchronous changesets are still pending, then the pending changesets will be applied synchronously before the new changeset is applied.

- (void)applyChangeset:(CKTransactionalComponentDataSourceChangeset *)changeset mode:(CKUpdateMode)mode userInfo:(NSDictionary *)userInfo

Declared In

CKCollectionViewTransactionalDataSource.h

– modelForItemAtIndexPath:

The model associated with a certain index path in the collectionView.

- (id<NSObject>)modelForItemAtIndexPath:(NSIndexPath *)indexPath

Return Value

The model associated with a certain index path in the collectionView.

As stated above components are generated asynchronously and on a backgorund thread. This means that a changeset is enqueued and applied asynchronously when the corresponding component tree is generated. For this reason always use this method when you want to retrieve the model associated to a certain index path in the table view (e.g in didSelectRowAtIndexPath: )

Declared In

CKCollectionViewTransactionalDataSource.h

– sizeForItemAtIndexPath:

The layout size of the component tree at a certain indexPath. Use this to access the component sizes for instance in a UICollectionViewLayout(s) or in a UICollectionViewDelegateFlowLayout.

- (CGSize)sizeForItemAtIndexPath:(NSIndexPath *)indexPath

Return Value

The layout size of the component tree at a certain indexPath. Use this to access the component sizes for instance in a UICollectionViewLayout(s) or in a UICollectionViewDelegateFlowLayout.

Declared In

CKCollectionViewTransactionalDataSource.h

– reloadWithMode:userInfo:

CKTransactionalComponentDataSource

- (void)reloadWithMode:(CKUpdateMode)mode userInfo:(NSDictionary *)userInfo

Declared In

CKCollectionViewTransactionalDataSource.h

– updateConfiguration:mode:userInfo:

CKTransactionalComponentDataSource

- (void)updateConfiguration:(CKTransactionalComponentDataSourceConfiguration *)configuration mode:(CKUpdateMode)mode userInfo:(NSDictionary *)userInfo

Declared In

CKCollectionViewTransactionalDataSource.h

– announceWillDisplayCell:

Sends -componentTreeWillAppear to all CKComponentControllers for the given cell. If needed, call this from -collectionView:willDisplayCell:forItemAtIndexPath:

- (void)announceWillDisplayCell:(UICollectionViewCell *)cell

Declared In

CKCollectionViewTransactionalDataSource.h

– announceDidEndDisplayingCell:

Sends -componentTreeDidDisappear to all CKComponentControllers for the given cell. If needed, call this from -collectionView:didEndDisplayingCell:forItemAtIndexPath:

- (void)announceDidEndDisplayingCell:(UICollectionViewCell *)cell

Declared In

CKCollectionViewTransactionalDataSource.h

  supplementaryViewDataSource

Supplementary views are not handled with components; the datasource will forward any call to collectionView:viewForSupplementaryElementOfKind:atIndexPath to this object.

@property (readonly, nonatomic, weak) id<CKSupplementaryViewDataSource> supplementaryViewDataSource

Declared In

CKCollectionViewTransactionalDataSource.h