Comments (6)
Hi. The issue here is delete().get() just creates the operation of type Scalar<Integer>
that has to evaluated. You can evaluate it by calling value()
or consume(Consumer<? super E> action)
. Something like:
Integer rowsDeleted = MyApplication.getInstance().getData().toBlocking().delete(City.class).get().value();
List<City> wasCities=MyApplication.getInstance().getData().select(City.class).get().toList(); // will be empty now
Will make this more clear in the examples and documentation. Sorry about any confusion. Thanks for reporting!
from requery.
Thanks! Looks complicated)
from requery.
The reason for that is the API is designed to be fully non-blocking/reactive. I agree its a little bit more complicated in blocking use cases, there will be some improvements there
from requery.
I know, but using retrofit+rxAndroid I need blocking operation inside onNext
. How can I do it simpler?
NetworkApi.getServerApi().getCities()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<List<City>>() {
@Override
public void onCompleted() {
sendBroadcast(new Intent(BroadcastHelper.ACTION_CITY_LOADED));
System.out.println("onCompleted");
}
@Override
public void onError(Throwable e)
{
...
}
@Override
public void onNext(List<City> cities) {
System.out.printf("onNext %s\n", cities);
if(cities!=null)
{
MyApplication.getInstance().getData().toBlocking().delete(City.class).get().value();
MyApplication.getInstance().getData().toBlocking().insert(cities);
}
}
});
from requery.
I'm not sure that's what you want because then you are doing the database operations on the main thread then. You probably want to use the rx map() operator to apply functions to the observable which can do the database work before the final subscription.
from requery.
Thank you! I did so and get more speed for UI.
from requery.
Related Issues (20)
- Preload associations HOT 1
- Is "type" word a reserved? HOT 2
- java.lang.NoClassDefFoundError in SchemaUpdater.update HOT 1
- override beforeExecuteQuery or add default where
- it is possible do delete all content without delete the tables?
- SELECT from WITH clause
- Issue updating from v1.5.1 to v1.6.1 for Android
- New to requery, not sure how to get entities from database
- Is requery support only in java 8? HOT 1
- [Question] Query's string for debug
- Possible to create field of Map type?
- how to set an attribute when it is a key generated type?
- Build error with AS 4.2 running java 11 HOT 1
- connection leak when rollback (reloaded) HOT 1
- How to create Entity with a dynamic table name
- Migrate away from JCenter HOT 3
- Migrate from RxJava2 to RxJava3
- kapt build error HOT 2
- Is this project dead? HOT 3
- Version no longer upgraded HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from requery.