davidmoten / davidmoten/rxjava-jdbc
db.select(sql).dependsOnOperator().getXXX() doesn't seem to work
- Dominant language
- Java
- Stars
- 801
- Forks
- 114
- Avg merge
- 1m
- Merged PRs (30d)
- 3
Description
Hi,
I have the following piece of code that doesn't seem to work as I want:
``` java
updateObservable = Observable.interval(0, 10, TimeUnit.SECONDS)
.doOnNext(s -> System.out.println("try " + s))
.lift(db
.select("SELECT id FROM mytable ORDER BY updated_at ASC")
.dependsOnOperator()
.getTupleN()
)
.doOnNext(s -> System.out.println("result " + s));
updateObservable.subscribe();
```
This prints out:
```
try 0
try 1
...
```
Although this seems to work fine:
``` java
updateObservable = Observable.interval(0, 10, TimeUnit.SECONDS)
.doOnNext(s -> System.out.println("try " + s))
.lift(db
.select("SELECT id FROM mytable WHERE id <> ? ORDER BY updated_at ASC")
.parameterOperator()
.getTupleN()
)
.doOnNext(s -> System.out.println("result " + s));
updateObservable.subscribe();
```
Because it prints the following:
```
try 0
result TupleN [values=[18]]
result TupleN [values=[16]]
result TupleN [values=[17]]
try 1
result TupleN [values=[18]]
result TupleN [values=[16]]
result TupleN [values=[17]]
...
```
**Am I doing something wrong in the first example ?**
FYI I've simplified the above example but what I really want to do is to continuously poll that request and process its elements. It would probably look like that:
``` java
updateObservable = Observable.interval(0, 1, TimeUnit.NANOSECONDS)
.onBackpressureLatest()
.lift(db
.select("SELECT id FROM mytable ORDER BY updated_at ASC")
.dependsOnOperator()
.getTupleN()
)
.> compose(new MyTableTransformer())
.lift(db
.update("UPDATE mytable SET updated_at = ? WHERE id = ?")
.parameterOperator()
);
updateObservable.subscribe();
```
Thanks
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.