Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
public class UsersPresenter extends Presenter<UsersPresenter.MyView, UsersPresenter.MyProxy>
implements UsersViewUiHandlers {
interface MyView extends View, HasUiHandlers<UsersViewUiHandlers> {
void displayUsers(List<User> users);
}
// ...
private final ResourceDelegate<UserApi> userApiResourceDelegate;
@Inject
UsersPresenter(
EventBus eventBus,
MyView view,
MyProxy proxy,
ResourceDelegate<UserApi> userApiResourceDelegate) {
super(eventBus, view, proxy, RevealType.Root);
this.userApiResourceDelegate = userApiResourceDelegate;
getView().setUiHandlers(this);
}
@Override
public void prepareFromRequest(PlaceRequest request) {
userApiResourceDelegate.withCallback(new RestCallbackImpl<List<User>>() {
@Override
public void onSuccess(List<User> users) {
getView().displayUsers(users);
}
}).getUsers();
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment