Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make section diffingKey parameter required #147

Merged
merged 4 commits into from
Oct 16, 2018

Conversation

ronaldsmartin
Copy link
Contributor

Changes in this pull request

Issue fixed: n/a

As discussed with @benasher44 and @noahsark769, this updates the initializers for TableSectionViewModel and CollectionSectionViewModel so that the diffingKey argument is required.

This prevents accidental misuse of the automatic diffing API, which is possible if you rely on the current default parameter value. 😅

No new behavior here, just a breaking API change. Tests are updated accordingly (no new ones).

Note on the parameter positioning

Previously diffingKey was the last parameter in each initializer. I chose to make it the first in the argument list:

Prefer to locate parameters with defaults toward the end of the parameter list

  • If we keep diffingKey close to the bottom as the last required parameter, it divides the required argument for the collection/table view models from the optional arguments for header and footer like so 🤮
TableSectionViewModel(
    cellViewModels: ...,
    diffingKey: nil,
    headerViewModel: ...,
    footerViewModel: ...
)

I like it at the beginning better because it kind of looks like a section name. Open to discussion if there are any objections, though!

Checklist

  • All tests pass. Demo project builds and runs.
  • I added tests, an experiment, or detailed why my change isn't tested.
  • I added an entry to the CHANGELOG.md for any breaking changes, enhancements, or bug fixes.
  • I have reviewed the contributing guide

@jessesquires
Copy link
Contributor

👍

@ronaldsmartin ronaldsmartin merged commit 8c7612d into master Oct 16, 2018
@ronaldsmartin ronaldsmartin deleted the make-diffing-key-nondefault branch October 16, 2018 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants