-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Can someone shed some light on an IGAssert in IGListBindingSectionController? #1174
Comments
Sure thing! This assert is in place b/c if your models return I could maybe see the need for this type of update in some cases. If that's the case, let us know. I'd be open to a PR converting this assert into a warning log. |
Thanks for the quick reply. I think our use case is a valid example of why it should not be an assert. We are showing/hiding questions in a survey. The header with the show/hide button is a section and each question is a section. Each section is using a IGListBindingSectionController. I believe the only way to animate the show/hide of questions is to call: Hope that makes sense. Let me know if you need more info or can think of another approach. |
@rnystrom, based on what you said earlier, are you recommending that we don't call If that's the case, is there a way to animate in cells for new sections to support show/hide functionality? |
@jeffbailey no you should be able to still call updates. If the object is hidden, we’d recommend you just relive the item from the top-level array. If you want to hide all the cells, but keep the section controller around, you can return 0 for Am I understanding your design correctly? Sent with GitHawk |
@rnystrom I think I understand what you're saying, but it does change our implementation a bit. Each question has its own section. When the survey first appears there's only one question shown (backed by 1 ListDiffable Question object and 1 section controller). When the "Show All" button is tapped, we call the adapter's performUpdates method to show all 5 questions. This results in all 5 ListDiffable objects being returned the other 4 section controllers getting created. I think you're suggesting we create all 5 section controllers up front, and have the other 4 return 0 for numberOfItems. When "Show All" is tapped, we then call the update method on each section controller. On the surface, our current approach seems cleaner to me and I'd advocate the assert by changed to a warning (at most). Let me know if I understood your suggestion correctly and if you still think its the right approach given this additional background info about our current setup. |
@jeffbailey hmm your approach sounds totally fine. I'm actually not sure why you're even hitting the assert in this case? Is the first question model changing after "show all" is tapped? |
@rnystrom Ah yes, I was oversimplifying. The first model is really for the state of the "Show All/Hide" button and its state changes when tapped to show/hide the questions. The diffIdentifier for the model remains unchanged, but the isEqual is different because of the change of show/hide state. So IGListKit uses the same section controller instance and calls didUpdateToObject to give it the new model. Sorry I left out that important detail! We have actually worked about the issue for now by using a UUID for the diffIdentifier which will trigger a new section controller being created. |
@jeffbailey should we close this out? Sent with GitHawk |
@rnystrom : Would you support a PR making this assert a warning instead? ... We're using IGListKit alongside ReSwift (redux, I'm sure you're a bit familiar being at FB), and consider this example: There's a contact section:
The consequences of this assert is that any time any model that is bound to a section controller changes, we need to call performUpdates on that controller for it to reload. It makes a lot more sense for it to be automatic. |
I would also like to see the assert turned into a warning and would be happy to do a pull request if you supported that @rnystrom. |
Changing the assert to a warning is a definitely good first step here in my opinion, but I don't think its enough, as I don't think there's enough documentation on why this is. Having ListBindingSectionController's
So I get this now after poking in the source code: an update to a ... but at least in my case, I don't want to reload a |
@SirensOfTitan @jeffbailey Ya I'm in support of changing this assert to simply a warning. I could see the case for wanting to totally reload the section. |
Great. I'd put a pull request together. |
Pull request has been submitted. To test the change, I updated |
hey @rnystrom I am actually using IGListKit for one of my VCs and this assertion is still there. It is not being flagged as a warning. I just started using it a few weeks ago thus I am pretty sure I am using the latest. Has the PR not been merged yet? |
@darsshanNair: Use master, I don't think there's been a formal release in a while. |
…ntire section. (Instagram#1213) Summary: Issue fixed: Instagram#1174 - [X] All tests pass. Demo project builds and runs. - [x] I added tests, an experiment, or detailed why my change isn't tested. - [X] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes. - [X] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md) Pull Request resolved: Instagram#1213 Differential Revision: D9003398 Pulled By: rnystrom fbshipit-source-id: 2c68f42e21abaea9191f26309668d866544f80b4
New issue checklist
README
and documentationGeneral information
IGListKit
version: 3.4.0Can someone help me understand the purpose in the IGAssert in the IGListBindingSectionController::didUpdateToObject method?
It is being triggered by a call to:
adapter.performUpdates(animated: true)
In order to show/hide some sections as well as update existing sections. I assume the assert is trying to point out a misuse of the API, but I must be missing something.
The text was updated successfully, but these errors were encountered: