RXJavaSupport
RXJava support in DBFlow is an incubating feature and likely to change over time. We support both RX1 and RX2 and have made the extensions + DBFlow compatibility almost identical - save for the changes and where it makes sense in each version.
Currently it supports
Any
ModelQueriablecan be wrapped in aSingle,Maybe, orFlowable(to continuously observe changes).Single +
Listmodelsave(),insert(),update(), anddelete().Streaming a set of results from a query
Observing on table changes for specific
ModelQueriableand providing ability to query from that set repeatedly as needed.
Getting Started
Add the separate packages to your project:
dependencies {
// RXJava3
compile "com.github.agrosner.dbflow:reactive-streams:${dbflow_version}"
}Wrapper Language
We can convert wrapper queries into different kinds of RX operations.
For a single query:
Using vanilla transactions:
Using RX:
Observable Queries
We can easily observe a query for any table changes (once per transaction) while it is active and recompute via:
This works across joins as well.
Model operations
Operations are as easy as:
Query Stream
We can use RX to stream the result set, one at a time from the ModelQueriable using the method queryStreamResults():
Last updated
Was this helpful?