greenrobot / objectboxrxjava Goto Github PK
View Code? Open in Web Editor NEWOptional RxJava 2 APIs for ObjectBox
License: Apache License 2.0
Optional RxJava 2 APIs for ObjectBox
License: Apache License 2.0
With the current Rx implementation, it's not possible to use find
for pagination.
Take RxQuery.single
for example. Since we pass Query<T>
and receive a Single<List<T>>
, we can't apply that operator.
I really don't have a suggestion on how to fix this decently. Right now, I'm doing:
Single.just(box.query()
.build()
.find(from, to)
)
Truth is that I would prefer a somewhat different Rx implementation. Something along the ways of requery (https://github.com/requery/requery).
Thank you.
Hello!
How can I save objects reactively?
I've got an exception
io.objectbox.exception.DbException: Entity is expected to have a no-arg constructor: Item
but it didn't surface until I've debugged it and captured it at BoxStore.java:670
When I subscribe to an observable such as RxQuery.observable(box.query().build())
and then delete all entities from the box via box.removeAll()
then it doesn't emit an empty list of entities.
I have a query value.
Query<Student> query = mStudentBox.query().contains(Student_.name, searchText).build();
query.subscribe().on(AndroidScheduler.mainThread()).observer(new DataObserver<List<Student>>() {
@Override
public void onData(List<Student> data) {
......
}
});
But i don't need List, i need a single value, like this:
Query<Student> query = mStudentBox.query().contains(Student_.name, searchText).build();
query.findFirst();
How i can do this ? How i can subscribe on this query ? I didn't find the solution.
Thank you for your time
I am getting this:
java.lang.NullPointerException: Attempt to invoke interface method 'void io.objectbox.reactive.DataSubscription.cancel()' on a null object reference
at io.objectbox.query.QueryPublisher.unsubscribe(QueryPublisher.java:105)
at io.objectbox.reactive.DataSubscriptionImpl.cancel(DataSubscriptionImpl.java:37)
at io.objectbox.rx.RxQuery$5$2.cancel(RxQuery.java:127)
at io.reactivex.internal.disposables.CancellableDisposable.dispose(CancellableDisposable.java:49)
at io.reactivex.internal.operators.single.SingleCreate$Emitter.onSuccess(SingleCreate.java:72)
at io.objectbox.rx.RxQuery$5$1.onData(RxQuery.java:120)
at io.objectbox.rx.RxQuery$5$1.onData(RxQuery.java:116)
at io.objectbox.query.QueryPublisher$2.run(QueryPublisher.java:84)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
The request looks like this:
Query<Item> query = itemBox.query()
.build();
return RxQuery.single(query)
.toObservable()
.flatMap(items -> Observable.fromIterable(items));
TL;DR: implementation 'io.objectbox:objectbox-rxjava:0.9.8'
does not work
Can you guys update it on which version is available? Thanks!
java.lang.NullPointerException: Attempt to invoke interface method 'void io.objectbox.reactive.DataSubscription.cancel()' on a null object reference
at io.objectbox.query.QueryPublisher.unsubscribe(QueryPublisher.java:89)
at io.objectbox.reactive.DataSubscriptionImpl.cancel(DataSubscriptionImpl.java:21)
at io.objectbox.rx.RxQuery$5$2.cancel(RxQuery.java:127)
at io.reactivex.internal.disposables.CancellableDisposable.dispose(CancellableDisposable.java:49)
at io.reactivex.internal.disposables.DisposableHelper.set(DisposableHelper.java:54)
at io.reactivex.internal.operators.single.SingleCreate$Emitter.setDisposable(SingleCreate.java:109)
at io.reactivex.internal.operators.single.SingleCreate$Emitter.setCancellable(SingleCreate.java:114)
at io.objectbox.rx.RxQuery$5.subscribe(RxQuery.java:124)
at io.reactivex.internal.operators.single.SingleCreate.subscribeActual(SingleCreate.java:39)
at io.reactivex.Single.subscribe(Single.java:2707)
at io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89)
at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:452)
at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:61)
at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:52)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
@Override
public synchronized void unsubscribe(DataObserver<List<T>> observer, @Nullable Object param) {
DataPublisherUtils.removeObserverFromCopyOnWriteSet(observers, observer);
if (observers.isEmpty()) {
objectClassSubscription.cancel(); // this line
objectClassSubscription = null;
}
}
subscribe method in QueryPublisher never call when i use Single , so objectClassSubscription be null
override fun get(): Single<List<Airport>> = RxQuery.single(box.query()
.equal(Airport_.deleted, 0)
.build())
when using Observable instead of Single, all be right
if(single) {
if(onlyChanges) {
throw new IllegalStateException("Illegal combination of single() and onlyChanges()");
}
publisher.publishSingle(observer, publisherParam);
} else {
publisher.subscribe(observer, publisherParam);
if(!onlyChanges) {
publisher.publishSingle(observer, publisherParam);
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.