lundi 23 juillet 2018

Android - MVP using Activity/Context

I've been dabbling with MVP for android and have read from different sites about not passing an activity as argument into the presenter as it's anti-pattern but i have come across a problem where i need to use a third party method that requires the activity/context.

I've thought of using Dependency Injection, doing another abstraction or just pass it only to the method that requires it, rather than the constructor but i'm confused with what's better.

An example in Kotlin (Presenter)

fun Food(*should activity be passed here?*) { 
var bar = Foo(activity).build

Stand(bar, callback{})
}

Would be great if someone can enlighten me on this.

Aucun commentaire:

Enregistrer un commentaire