GithubHelp home page GithubHelp logo

Backfiring pattern? about nucleus HOT 11 CLOSED

konmik avatar konmik commented on June 28, 2024
Backfiring pattern?

from nucleus.

Comments (11)

konmik avatar konmik commented on June 28, 2024

I think that Presenter should not tell view to show something. Presenter in not controller. MVC does not work on Android, see "best practices" section.

I don't know what your Settings object is doing, but it seems to me that you can put all this code into your activity.

from nucleus.

konmik avatar konmik commented on June 28, 2024

Yes, you can use onTakeView to push data from presenter to view if that data is needed every time a view is attached.

from nucleus.

jofor avatar jofor commented on June 28, 2024

I would think this pattern becomes a little weird. Because this means you should at some cases couple activities with presenters and some not. Else you'll leave empty presenters around for no reason.

Imagine you have an application that has a simple wizard. The only thing that activity should do is present static views and during the wizard maybe write settings that will be saved in your application.

If code such the one above is supposed to be placed in the activity it means i should decouple the presenter for that specific activity, which would break the mvp-pattern.

Does not the mvp-pattern say you should couple: model->presenter->view to display something and the other way around view->presenter->model to store something?

You probably know more than me, but I know this for sure, there will be cases when the presenters will not be used for anything, which strikes me as odd :)

from nucleus.

konmik avatar konmik commented on June 28, 2024

Reading preferences is not a task that deserves presenter. This is a one-line main thread action. Keep it stupid simple!

Yes, I use presenter only if I have background tasks to handle or if my database should be split off view. Overengineering is a real problem on big projects, this is why not every view should have them.

from nucleus.

jofor avatar jofor commented on June 28, 2024

I'll try stick with that reference :)

from nucleus.

konmik avatar konmik commented on June 28, 2024

You can create an observable from preferences if you wish and use deliver() to send data to view.

from nucleus.

jofor avatar jofor commented on June 28, 2024

If one is to be able to make a project-specific baseactivity that makes easy interaction with both activities not using presenters and activities using presenters, I think a new annotation would have to be added in that case :)

if RequiresPresenter-annotation is used to tell that an activitiy needs a presenter, then it should be possible to also tell with an annotation that it does not need it, else you'll have to use two baseactivities for your activities, one that uses nucleusActivity and one that does not :)

from nucleus.

konmik avatar konmik commented on June 28, 2024

If you make a project-specific base activity then just don't say that it requires a presenter. :-D

from nucleus.

jofor avatar jofor commented on June 28, 2024

Then how will I make an activity than needs to be extended from that baseactivity that DOES require a presenter? :D

I tried the following

  public class BaseActivity<PresenterType extends nucleus.presenter.Presenter> extends     NucleusActionBarActivity<PresenterType> {
}

But if you remove the RequiresPresenter-annotation from the activities extending from it, and I just got an error that I needed to declare a Presenter for the activites using that baseactivity :)
So that didnt seem to work

It does seem like an issue

from nucleus.

konmik avatar konmik commented on June 28, 2024

Ok, I will check this. Thank you for the report.

from nucleus.

konmik avatar konmik commented on June 28, 2024

Done! :) 1.1.0

from nucleus.

Related Issues (20)

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.