Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better asynchronous transactions #44

Closed
gfx opened this issue Dec 8, 2015 · 1 comment
Closed

Better asynchronous transactions #44

gfx opened this issue Dec 8, 2015 · 1 comment

Comments

@gfx
Copy link
Member

gfx commented Dec 8, 2015

Something like this?

    interface AsyncTransactionTask<T> {
        Single<T> execute();
    }

    public <T> Single<T> transactionAsync(@NonNull final AsyncTransactionTask task) {
        return Single.create(new Single.OnSubscribe<Single<T>>() {
            @Override
            public void call(SingleSubscriber<? super Single<T>> subscriber) {
                subscriber.onSuccess(task.execute());
            }
        }).flatMap(new Func1<Single<T>, Single<? extends T>>() {
            @Override
            public Single<? extends T> call(Single<T> single) {
                return single;
            }
        });
    }
@gfx gfx added the enhancement label Dec 8, 2015
@gfx gfx changed the title Better asynchronous transaction Better asynchronous transactions Dec 8, 2015
@gfx gfx added the wontfix label Dec 9, 2015
@gfx
Copy link
Member Author

gfx commented Dec 9, 2015

I have tried some transaction APIs based on observables, but they are difficult to understand.

I'll provide a low-level interface for transactions to use them with asynchronous tasks, and transactionAsync() will be removed.

@gfx gfx closed this as completed Dec 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant