Last active
April 8, 2018 17:00
-
-
Save rajeshct/df56c88d1f83488e0b9203e1b77be2ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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