Skip to content
This repository has been archived by the owner on Sep 2, 2020. It is now read-only.

onSuccessInUi() shortcut for onSuccess(..., Task.UI_THREAD_EXECUTOR)? #132

Open
wrozwad opened this issue May 22, 2017 · 1 comment
Open

Comments

@wrozwad
Copy link

wrozwad commented May 22, 2017

We often use yours lib for some async operations and after that we inform user about status operation. So almost every time we write something like:

Task.callInBackground(() -> {
    // do something extra heavy
    return someReturnObject;
})
    .onSuccess(new Continuation<SomeReturnObject, Void>() {
        @Override
        public Void then(Task<SomeReturnObject> task) throws Exception {
            Toast.makeText(context, task.getResult().getSomethingNicely(), Toast.LENGTH_SHORT).show();
            return null;
        }
    }, Task.UI_THREAD_EXECUTOR);

As many people we're lazy, forgetful and will be in ecstasy if we can write this in simpler form:

...
.onSuccessInUi(new Continuation<SomeReturnObject, Void>() {
    @Override
    public Void then(Task<SomeReturnObject> task) throws Exception {
        Toast.makeText(context, task.getResult().getSomethingNicely(), Toast.LENGTH_SHORT).show();
        return null;
    }
});

Any thoughts about this idea? 😉

@wrozwad wrozwad changed the title onSuccessInUi() shortcut? onSuccessInUi() shortcut for onSuccess(..., Task.UI_THREAD_EXECUTOR)? May 22, 2017
@natario1
Copy link

I think that would create more confusion, right now it’s verbose but clear..

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants