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

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

Description

@wrozwad

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? 😉

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions