Open li-bei opened 4 years ago
Thanks for the suggestion. I believe my first iteration tried this but I later regreted it.
Reasons:
cellProvider
seem to be a little harder to follow than plain UITableViewDataSource -- it makes me jump back and forth when following the code.I do like the idea of simple adoption without these glue code. Would it be possible to make subclass(or protocol, I don't know) for FormDataSource
, so that it conforms to UITableViewDataSources
automatically? If there is PR that we can discuss, it would be great.
Again, thanks for making this discussion to make this project better 👍
Looked at the code, I think I was wrong. Because baseRow must contains a UITableViewCell, there is no reason for the user to use this library in other views than UITableView. Making this library too generic doesn't seem to be a good idea to me.
So I actually think it would be great to implement what you said.
One more thought.
When using ObjectForm, I have come into some scenarios where form rows are not the only rows in my UITableView. For example, I have other dataSource and might want to add code in UITableViewDataSource to provide custom cells or custom headers. Is it possible to achieve with UITableViewDiffableDataSource
? The user might have to make a custom BaseRow to add simple cells to UITableView, which would end up with some dirty workarounds.
I am worrying about losing the transparency and take freedom from the user. Maybe a subclass for the user to choose will work.
I think
FormDataSource
should be a concrete class that implementsUITableViewDataSource
, just like whatUITableViewDiffableDataSource
does. In this way, developers can useFormDataSource
directly:instead of typing lots of glue code, such as in example: