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

Interactor what in MVP #28

Closed
tangdekun opened this issue Dec 20, 2016 · 11 comments
Closed

Interactor what in MVP #28

tangdekun opened this issue Dec 20, 2016 · 11 comments

Comments

@tangdekun
Copy link

Why do we use Interactor in Mvp ?Presenter can maka it What Interactor do,can I see it as a model?or,it is a model

@antoniolg
Copy link
Owner

Interactors are an important part of many clean architectures, and are use cases of the App. It's true they are not very important in this example if the only goal is to learn MVP.

@tangdekun
Copy link
Author

Are Interactors used to manage data Like Model in MVP?

@antoniolg
Copy link
Owner

They are the part of the model that the presenters interact with, yeah.

@tangdekun
Copy link
Author

Thank you very much

@szaboa
Copy link

szaboa commented Jan 6, 2017

For every use case, for example getting user profile and updating user profile I should create a separate interactor?

@OrdonTeam
Copy link

I would create at least separate interfaces. In some cases both could be implemented by one class.

@yelsane
Copy link

yelsane commented Aug 2, 2017

Hi Antonio. Got here after going through your site. I was hoping to get your advice about the flow I have going. It goes like this.

Activity > Presenter > Interactor > Helper
Activity < Presenter < Interactor < Helper

  • Activity - represents the view.
  • Presenter - the presenter class.
  • Interactor - the class that directly interacts with the helper and presenter classes. One separate interactor for each Helper class, implementing pretty much the callbacklisteners and corresponding presenter methods.
  • Helper - a specific class I use for Firebase DB calls.

Does how I use the interactor make sense here? Cheers!

@antoniolg
Copy link
Owner

@yelsane usually an interactor is usually called use case. It's a specific action that the user or our App starts. Usually an interactor tends to have just one execute method, because the name of the interactor itself already gives enough info.

There are some variations of this, but that usually is the way to use it. If your interactors are having that meaning, then I don't see anything wrong on the flow you describe. Looks good to me.

@yelsane
Copy link

yelsane commented Aug 9, 2017

@antoniolg Thank you so much for taking the time to provide feedback Antonio. I'll proceed with what I already have then. Cheers! 👍 👍

@MahmoudAmin39
Copy link

In this example you have made an interactor (which represents the model layer in MVP) instance in the presenter class but i know that model is represented as Singleton in the MVP architecture so is there a difference or affect on app performance
and which is better after all???

@antoniolg
Copy link
Owner

Well, singletons has their own problems. Main one is that it's difficult to implement, but also you have it in memory even when you don't use it.

If you are sure that it needs to be a singleton, I'd just make classes unaware of this implementation detail, by declaring the dependency in the constructor of the classes that use it.

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

6 participants