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

Passing data from One screen to another #1

Open
ghost opened this issue Jun 25, 2014 · 7 comments
Open

Passing data from One screen to another #1

ghost opened this issue Jun 25, 2014 · 7 comments

Comments

@ghost
Copy link

ghost commented Jun 25, 2014

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

@cnstoll
Copy link
Contributor

cnstoll commented Jun 26, 2014

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,

  • Conrad

@sebastianwr
Copy link

Sorry for bothering you on multiple channels, @cnstoll
I just found this and think GitHub is the best place to discuss this issue.

For a simple master-detail view, I would enhance the View Model with the properties needed for both master and detail view.

List View (Table Cell tapped) -> List Presenter ---(ViewModel)---> List Wireframe ---(ViewModel)---> Detail Wireframe --> ... -> 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?

@daria-kopaliani
Copy link

This would be very useful for me as well. Thanks in advance.

@onmyway133
Copy link

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

@ghost
Copy link

ghost commented Mar 15, 2015

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:

- (void)updateEntryWithName:(NSString *)name dueDate:(NSDate *)dueDate;

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.

@daria-kopaliani
Copy link

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)?

@ghost
Copy link

ghost commented May 8, 2015

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.

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