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

implement "modelSelected" and more methods "combine way" for UICollectionView and UITableview #11

Open
nathan-hh opened this issue Jul 16, 2020 · 8 comments

Comments

@nathan-hh
Copy link

No description provided.

@nathan-hh nathan-hh changed the title implement "didselect" and more methods "combine way" for collectionview and table view implement "didSelectModel" and more methods "combine way" for UICollectionView and UITableview Jul 17, 2020
@nathan-hh nathan-hh changed the title implement "didSelectModel" and more methods "combine way" for UICollectionView and UITableview implement "modelSelected" and more methods "combine way" for UICollectionView and UITableview Jul 17, 2020
@icanzilb
Copy link
Collaborator

I think this might be useful - currently the api allows you to implement this via table delegates but having something along the lines of what RxDataSources has would be fine. I always had an issue with the fact that RxDataSources is supposed to be a data-source but it does user input handling as well, but honestly is the simplest way and people seem to like it so who am I to argue with that :)

@nathan-hh do you have a list in mind of which methods besides modelSelected you'd like to see implemented?

@nathan-hh
Copy link
Author

@freak4pc i saw that you updated "delegate proxy" on CombineCocoa but didn't tag it for Pod version yet..
@icanzilb to solve this issue i guess need to use CombineCocoa library. is it ok if i'll do it?

@freak4pc
Copy link
Member

@nathan-hh there seems to be some bug in it with the latest version of Xcode / Swift. @jdisho is working on it AFAIK.

@kevinrenskers
Copy link

kevinrenskers commented Oct 2, 2020

I would love this! This is how I currently deal with selection using the delegate proxy stuff from CombineCocoa.

viewModel.models
  .bind(subscriber: collectionView.itemsSubscriber(cellIdentifier: Cell.reuseIdentifier, cellType: Cell.self) { cell, _, model in
    cell.configure(model: model)
  })
  .store(in: &subscriptions)

collectionView.didSelectItemPublisher
  .combineLatest(viewModel.models)
  .map { indexPath, models in
    models[indexPath.item]
  }
  .sink { model in
    // Do whatever you want with the model
  }
  .store(in: &subscriptions)

Not having to do the translation from the IndexPath to a model would be pretty nice :)

@freak4pc
Copy link
Member

freak4pc commented Oct 2, 2020

Right, to be honest I'm not 100% sure you could deal with it in the context of this repo without copy-pasting all of the DelegateProxy stuff or have CombineExt as a dependency

@kevinrenskers
Copy link

Maybe some conditional imports and functions for if the user happens to have both modules installed?

@freak4pc
Copy link
Member

freak4pc commented Oct 2, 2020

Sounds more reasonable to have a RxDataSourcesCore and RxDataSources (or the other way - RxDataSourcesModel vs. RxDataSources) , different dependencies

@nathan-hh nathan-hh reopened this Oct 2, 2020
@nathan-hh
Copy link
Author

@freak4pc i forked and i'll solve it with CombineCocoa library.
i'll pull request and let @icanzilb to decide

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants