-
Notifications
You must be signed in to change notification settings - Fork 15
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
Passing data from One screen to another #1
Comments
I agree this is worth doing. As an example use-case, what do you think about the notion of "editing" a TODO after you've created it? Would that exhibit the behavior you're hoping to see? Thanks,
|
Sorry for bothering you on multiple channels, @cnstoll For a simple master-detail view, I would enhance the View Model with the properties needed for both master and detail view.
For an editing matter you could hold a reference to the database ID, but that would be a violation of the layer independence? I really don't know. Do you have any working implementations yet? |
This would be very useful for me as well. Thanks in advance. |
How about passing the ToDoItem from List View (row tapped) -> List Presenter (event handler) -> List Wireframe -> Detail Wireframe Think of the Wireframe as the gateway and also the input for its module |
The editing use case would not be much different from adding, the primary difference being that you need to have a way of identifying the TodoItem you want to edit. You shouldn't pass the actual TodoItem from the List view but get a new copy of the data in your editing interface. The only identifying information for a TodoItem you have in the List UI is the name and due date, so the List module interface could define a new method for updating:
The rest of the behavior would follow closely to what is done with adding, the exception being that the Update module would receive entity data to pre-populate its view. You could even consider abstracting the editing interface as its own view controller and then add it as a child view controller in both the Add and Update modules. |
Hi @adamschlag, what about the case when you do not have all the information about the todo item in the List view, you need for Editing view? (I.e. you only show name and date on List view, but, let's imagine there is more to todo item and you can edit in Editing view). Would you then pass the ID of the todo item to Editing wireframe, so that Editing provider could fetch all the data from the model (server or database)? |
Yes, at least that is what I've done. That way you don't have to pass more data than you need to any of your presentation modules, but you have a way to tie data together when navigating to a module that requires more detail. |
Hey Guys, could you please add an update to the current TODO demo showing how to pass data from one screen to another. For example, when the user selects a TODO, showing that selected ToDo on a ToDoDetailViewController. This will give us a much needed understanding of how we can accomplish such stuff by making correct use of VIPER architecture.
Thanks a lot
The text was updated successfully, but these errors were encountered: