Clean-Swift / CleanStore

A sample iOS app built using the Clean Swift architecture. Clean Swift is Uncle Bob's Clean Architecture applied to iOS and Mac projects. CleanStore demonstrates Clean Swift by implementing the create order use case described by in Uncle Bob's talks.
https://clean-swift.com/clean-swift-ios-architecture/
MIT License
1.91k stars 315 forks source link

Question: Should the data source of the router be an interactor or a presenter? #39

Open ozgunsimsek opened 11 months ago

ozgunsimsek commented 11 months ago

Let's consider a scenario: we've sent the model obtained in the interactor to the presenter to convert it into a presentable format. In the presenter, one element's index within this data was changed. Let's assume that this change is solely related to the presentation layer. (For example, within the "members" array, the presenter identified the current member and moved them to the first position).

After this stage, if the router uses the interactor as its data source, when a user selects an index, they might access the wrong index. In other words, if the user action triggers the router, and what the user clicked is provided by the presenter, shouldn't the router get the data from the presenter to ensure accessing the correct data?

catchakos commented 10 months ago

Could either store the presented array in the interactor and have the change reflected there, or could ask the presenter to convert between originalArray index and presentedArray index. I've used both, I suppose it depends on how you want to consider this presentation re-ordering, as a mere presentation thing or as some real re-ordering that could be persisted/uploaded etc.