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

RxJava only works with Queries? #162

Closed
wengelef opened this issue Sep 24, 2017 · 9 comments
Closed

RxJava only works with Queries? #162

wengelef opened this issue Sep 24, 2017 · 9 comments

Comments

@wengelef
Copy link

wengelef commented Sep 24, 2017

Is it not possible (out of the box) to use RxJava for insert/update?
Like return a Flowable<Long> or Flowable<Any> instead.

@mynote
Copy link

mynote commented Sep 28, 2017

Since you use LiveData to listen for changes, you may use RxJava to listen for changed by observing Select * ...

The return value of update/delete are the row/inserted id which isnt used to observe for changes. If you really want to get this value in a different Thread use Flowable.fromCallable() Flowable.create() or Flowable.just().

I think this may be the reason for that.

@florina-muntenescu
Copy link
Contributor

There is already a bug raised for this on the official bug tracker, here.

@birender-s
Copy link

i am also looking forward for this feature availability

@XtreeIvI
Copy link

1+

@florina-muntenescu
Copy link
Contributor

RxJava is supported for insert/update/delete since Room 2.1.0-alpha01

@proninyaroslav
Copy link

@florina-muntenescu What about LiveData support?

@involve-it
Copy link

RxJava is supported for insert/update/delete since Room 2.1.0-alpha01

Could you please give us a hint on how to use it with room's insert/update/delete?

@proninyaroslav
Copy link

proninyaroslav commented Feb 14, 2019

@involve-it
For example:

@Insert
Single<List<Long>> add(Foo... f); /* Id of added rows */

@Delete
Single<Integer> delete(Foo... f); /* Num of deleted rows */

@Update
Single<Integer> update(Foo... f); /* Num of updated rows */

And how to observe it:

Disposable d = db.fooDao().add(new Foo("bar"))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(ids -> /* Do stuff */);
disposables.add(d);

@involve-it
Copy link

@involve-it
For example:

@Insert
Single<List<Long>> add(Foo... f); /* Id of added rows */

@Delete
Single<Integer> delete(Foo... f); /* Num of deleted rows */

@Update
Single<Integer> update(Foo... f); /* Num of updated rows */

And how to observe it:

Disposable d = db.fooDao().add(new Foo("bar"))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(ids -> /* Do stuff */);
disposables.add(d);

Awesome, thanks!

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

No branches or pull requests

7 participants