GithubHelp home page GithubHelp logo

Interactor what in MVP about androidmvp HOT 11 CLOSED

antoniolg avatar antoniolg commented on June 14, 2024
Interactor what in MVP

from androidmvp.

Comments (11)

antoniolg avatar antoniolg commented on June 14, 2024 1

@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.

from androidmvp.

antoniolg avatar antoniolg commented on June 14, 2024

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.

from androidmvp.

tangdekun avatar tangdekun commented on June 14, 2024

Are Interactors used to manage data Like Model in MVP?

from androidmvp.

antoniolg avatar antoniolg commented on June 14, 2024

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

from androidmvp.

tangdekun avatar tangdekun commented on June 14, 2024

Thank you very much

from androidmvp.

szaboa avatar szaboa commented on June 14, 2024

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

from androidmvp.

OrdonTeam avatar OrdonTeam commented on June 14, 2024

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

from androidmvp.

yelsane avatar yelsane commented on June 14, 2024

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!

from androidmvp.

yelsane avatar yelsane commented on June 14, 2024

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

from androidmvp.

MahmoudAmin39 avatar MahmoudAmin39 commented on June 14, 2024

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

from androidmvp.

antoniolg avatar antoniolg commented on June 14, 2024

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.

from androidmvp.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.