Skip to content

What you think about DefereedObject instead of callbacks? #231

Closed
@lexer

Description

@lexer
AsyncResult<ResultClass> doSmth(String param1);

Usage:

AsyncResult<ResultClass> result = apiClient.getSmth("foo");

result.onSuccess(new ResultCallback<ResultClass>(ResultClass result) { ... } );
result.onError(new ErrorCallback<ErroClass>(ErrorClass err) { ... } );
result.onFinally(new Runnable() { ... } );

Also we can do sync call:

ResultClass res = result.doSync();

It is very close to Guava ListenableFutures https://code.google.com/p/guava-libraries/wiki/ListenableFutureExplained. The only difference that ListenableFuture cannot execute itself and you have to execute them with another object.

I also like that with Guava ListenableFutures async operations can be merged to be executed in parallel or one by one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions