Skip to content

Instantly share code, notes, and snippets.

@sockeqwe
Created October 24, 2017 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sockeqwe/1deb00dc31e360f222e20e04e9ca9737 to your computer and use it in GitHub Desktop.
Save sockeqwe/1deb00dc31e360f222e20e04e9ca9737 to your computer and use it in GitHub Desktop.
class MyFormPresenter extends MviBasePresenter<MyFormView, FormViewState> {
@Override
public void bindIntents(){
Observable<FormViewState> state = intent( MyFormView::submitIntent)
.map(formInputData -> new FormViewState( isValidName(formInputData.name), isValidEmail(formInputData.email) ) );
subscribeViewState(state, MyFormView::render)
}
}
class FormInputData{
String name;
String email;
}
class FormViewState {
boolean nameError;
boolean emailError;
}
interface MyFormView{
Observable<FormInputData> submitIntent();
void render(FormViewState state);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment