Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds a few utilities for synchronously unwrapping a Store with optional state.
Discussion:
In chatting with a few of the other UIKit + TCA developers, It seems like the DataSource pattern in UIKit is an awkward seam to transcend. Some folks are using the publisher version of
ifLetto reconcile the optionality of indexing into anIdentifiedArray, and later (but in practice, immediately) assigning the unwrapped store to their cell. They are maintaining a parallel dictionary ofAnyCancellablesjust to facilitate this unwrapping.I'd wager its an anti-pattern to fight the datasource pattern and circumvent its reload mechanics with a direct subscription to CellState. I'd like to encourage folks to wire their
UICollectionView.dataSourceto be derived from their ViewStore, and for the dataSource to refresh in response to the Store.A small step in the right direction, or a conversation starter at least, would be to expose some synchronous unwrapping of a store with optional state.
Here is how i'm using it in my project: