Pull request Potential fix for invalidation crashes on composed-swift/ComposedUI
As mentioned in https://github.com/composed-swift/ComposedUI/issues/13 and https://github.com/composed-swift/ComposedUI/issues/8 there are some scenarios where the collection view’s data is out-of-sync with the data in composed.
As mentioned in https://github.com/composed-swift/ComposedUI/issues/13 calling layoutIfNeeded
can trigger the data to be in sync again. In this I have added it to mappingWillBeginUpdating(_:)
which appears to solve the problem.
It might be needed in replace(sectionProvider:)
(because reloadData
is called) and/or mappingDidInvalidate(_:)
(for the same reason) but I’m still investigating.
I have validated this fix against https://github.com/composed-swift/ComposedUI/issues/8 and it fixes the crash.
https://github.com/composed-swift/ComposedUI/issues/13 still needs to be investigated and may require layoutIfNeeded
to be called in mappingDidInvalidate
. Marking as a draft until this is checked.