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

How to manage inputs from the cells of a Table/CollectionView the Rx way? #1

Open
FredericRuaudel opened this issue Feb 3, 2020 · 1 comment

Comments

@FredericRuaudel
Copy link

FredericRuaudel commented Feb 3, 2020

Hi @danielt1263 !

First, thanks for your nice example, I really like your very functional style in this project and also in RxMyCoordinator 💯

I have a question for you. How would you deal with an input control added inside a cell ?

For example, in this project, let's say your project owner ask you to add a "more information" button directly inside an Earthquake cell because a user interview showed that it was an action done really often.

How would you make the tap input of this button reachable from the Coordinator in order to process the opening of the SFSafariVC without relying on any of the UITableViewDelegate methods ?

  • Would you create a delegate to the cell and manage the Rx connection inside the TableVC (not very Rx minded, IMHO) ?
  • Would you create a "RX view model" and have the cell conforms to HasViewModel and coordinate everything in any way (didn't find a clean way to do that yet) ?
  • Would you make the cell implement some "rx" extension that allow the tableView to connect to it?

I'm curious to know your answer because I have a settings VC with lots of different inputs inside each cells and a dynamic layout where some inputs make other cells appear and disappear and I can't find a proper way to implement this…

Thanks in advance for your insight about this !

@danielt1263
Copy link
Owner

In this case, I would have a subject inside the viewDidLoad or bind function that accepted a cell id or model. Then in the cellForRowAtIndexPath I would bind the button to that Subject (make sure the subscription is disposed by the cell's disposeBag which is deinited in the prepareForReuse method.) That subject would then be a cause for an effect which in this case would be presenting the safari view.

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

2 participants