From 4534bc06f5f26f4b15f45b93eb904c98ffe7d272 Mon Sep 17 00:00:00 2001 From: John Estropia Date: Wed, 16 Jun 2021 23:28:46 +0900 Subject: [PATCH] Add utility for DiffableDataSources to create an empty snapshot for custom list construction --- Sources/DiffableDataSource.BaseAdapter.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sources/DiffableDataSource.BaseAdapter.swift b/Sources/DiffableDataSource.BaseAdapter.swift index eae290b..bf04b22 100644 --- a/Sources/DiffableDataSource.BaseAdapter.swift +++ b/Sources/DiffableDataSource.BaseAdapter.swift @@ -154,6 +154,17 @@ extension DiffableDataSource { completion: completion ) } + + /** + Creates a new empty `ListSnapshot` suitable for building custom lists inside subclass implementations of `apply(_:animatingDifferences:completion:)`. + */ + public func makeEmptySnapshot() -> ListSnapshot { + + return .init( + diffableSnapshot: .init(), + context: self.dataStack.unsafeContext() + ) + } /** Returns the number of sections