Skip to content

Instantly share code, notes, and snippets.

@rajeshct
Last active April 8, 2018 17:00
Show Gist options
  • Save rajeshct/df56c88d1f83488e0b9203e1b77be2ec to your computer and use it in GitHub Desktop.
Save rajeshct/df56c88d1f83488e0b9203e1b77be2ec to your computer and use it in GitHub Desktop.
class Presenter {
Interactor interactor;
IUiCallback uiCallback;
public void login(String userName, String password) {
interactor.performLogin(userName, password, new ErrorOrSuccessCallback() {
public void onSuccess(Object obj) {
prepareDataForUi(obj);
}
public void onError(String message) {}
};
}
private void prepareDataForUi(Object obj) {
uiCallback.updateUi(...);
}
}
class Interactor {
public void login(String userName, String password, ErrorOrSuccessCallback callback) {
if (success) {
callback.onSuccess(obj);
} else {
callback.onError(“Error”);
}
}
interface ErrorOrSuccessCallback {
void onSuccess(Object object);
void onError(String message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment