diff --git a/Sources/DataSources/ASCollectionNode+Rx/ASCollectionSectionedDataSource.swift b/Sources/DataSources/ASCollectionNode+Rx/ASCollectionSectionedDataSource.swift index a293fc2..010f705 100644 --- a/Sources/DataSources/ASCollectionNode+Rx/ASCollectionSectionedDataSource.swift +++ b/Sources/DataSources/ASCollectionNode+Rx/ASCollectionSectionedDataSource.swift @@ -29,11 +29,14 @@ open class ASCollectionSectionedDataSource: NSObject, ASCol } fileprivate static func configureCellBlockNotSet(dataSource: ASCollectionSectionedDataSource, node: ASCollectionNode, indexPath: IndexPath, model: I) -> ASCellNodeBlock { - return { dataSource.collectionNode(node, nodeForItemAt: indexPath) } + // Users expect collectionNode(_:nodeForItemAt:) will be executed in main thread + let cellNode = dataSource.collectionNode(node, nodeForItemAt: indexPath) + return { cellNode } } fileprivate static func configureSupplementaryViewBlockNotSet(dataSource: ASCollectionSectionedDataSource, node: ASCollectionNode, nodeForSupplementaryElementOfKind kind: String, indexPath: IndexPath) -> ASCellNodeBlock { - return { dataSource.collectionNode(node, nodeForSupplementaryElementOfKind: kind, at: indexPath) } + // Users expect collectionNode(_nodeForSupplementaryElementOfKind:at:) will be executed in main thread according to api doc. + return { DispatchQueue.main.sync(execute: { dataSource.collectionNode(node, nodeForSupplementaryElementOfKind: kind, at: indexPath) }) } } public init( diff --git a/Sources/DataSources/ASTableNode+Rx/ASTableSectionedDataSource.swift b/Sources/DataSources/ASTableNode+Rx/ASTableSectionedDataSource.swift index e39932c..1a15674 100644 --- a/Sources/DataSources/ASTableNode+Rx/ASTableSectionedDataSource.swift +++ b/Sources/DataSources/ASTableNode+Rx/ASTableSectionedDataSource.swift @@ -35,7 +35,9 @@ open class ASTableSectionedDataSource: NSObject, ASTableDat } fileprivate static func configureCellBlockNotSet(dataSource: ASTableSectionedDataSource, node: ASTableNode, indexPath: IndexPath, model: I) -> ASCellNodeBlock { - return { dataSource.tableNode(node, nodeForRowAt: indexPath) } + // Users expect taleNode(_:nodeForRowAt:) will be executed in main thread + let cellNode = dataSource.tableNode(node, nodeForRowAt: indexPath) + return { cellNode } } #if os(iOS) diff --git a/Sources/DataSources/ASTableNode+Rx/RxASTableAnimatedDataSource.swift b/Sources/DataSources/ASTableNode+Rx/RxASTableAnimatedDataSource.swift index 0a64996..8cf9269 100644 --- a/Sources/DataSources/ASTableNode+Rx/RxASTableAnimatedDataSource.swift +++ b/Sources/DataSources/ASTableNode+Rx/RxASTableAnimatedDataSource.swift @@ -150,6 +150,6 @@ open class RxASTableAnimatedDataSource: ASTableSe tableNode.reloadData() } } - }.on(observedEvent) + }.on(observedEvent) } } diff --git a/Sources/DataSources/ASTableNode+Rx/RxASTableReloadDataSource.swift b/Sources/DataSources/ASTableNode+Rx/RxASTableReloadDataSource.swift index 365ab88..08b1cd3 100644 --- a/Sources/DataSources/ASTableNode+Rx/RxASTableReloadDataSource.swift +++ b/Sources/DataSources/ASTableNode+Rx/RxASTableReloadDataSource.swift @@ -29,6 +29,6 @@ open class RxASTableReloadDataSource: ASTableSectionedDataS dataSource.setSections(element) tableNode.reloadData() } - }.on(observedEvent) + }.on(observedEvent) } }