sockeqwe / mosby

A Model-View-Presenter / Model-View-Intent library for modern Android apps
http://hannesdorfmann.com/mosby/
Apache License 2.0
5.49k stars 841 forks source link

Introducing MviView interface, which ensures "render()" method implementation #258

Closed regmoraes closed 6 years ago

regmoraes commented 7 years ago

Actualy, if we want to use the MVI library, we should make the View ( Activities and Fragments) implements the MvpView interface, and be sure to create and implement the render method, which takes a ViewState as parameter.

How about create a MviView typed interface that has a render(Type viewState) and extends MvpView? This way, every time we make a View implement the proposed MviView it's forced to override the render method.

Sugestion of implementation

public interface MviView<VS> extends MvpView {

    public void render(VS viewstate);
}

Usage example

public class MainActivity extends Activity implements MviView<SomeViewState> {

   (...)

   @Override
    public void render(SomeViewState viewstate){

     // Custom implementation
   }
}
sockeqwe commented 7 years ago

We already had this discussion. I would prefer to not be that opinionated about certain things i.e. naming it render()

Rômulo Eduardo Garcia Moraes notifications@github.com schrieb am Do., 29. Juni 2017, 04:37:

Actualy, if we want to use the MVI library, we should make the View ( Activities and Fragments) implements the MvpView interface https://github.com/sockeqwe/mosby/blob/master/mvp-common/src/main/java/com/hannesdorfmann/mosby3/mvp/MvpView.java, and be sure to create and implement the render method, which takes a ViewState as parameter.

How about create a MviView typed interface that has a render(Type viewState) and extends MvpView? This way, every time we make a View implement the proposed MviView it's forced to override the render method.

Sugestion of implementation

public interface MviView extends MvpView {

public void render(VS viewstate);

}

Usage example

public class MainActivity extends Activity implements MviView {

(...)

public void render(SomeViewState viewstate){

} }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sockeqwe/mosby/issues/258, or mute the thread https://github.com/notifications/unsubscribe-auth/AAjnrnIfkQczbb6AX3VC8fkK0QT_qIaSks5sIw3cgaJpZM4OIwgf .