Hello! I tried to play with this example - <https:...
# rx
Hello! I tried to play with this example - https://github.com/thomasnield/rxkotlinfx-tornadofx-demo . Using RxJava-JDBC by David Moten. Got a question. If i throw an exception in a Rx query to the database, when I try to make a query after the exception was thrown, database will return me an empty observable. How can I make it work again after an exception was throws? .flatMap { if(it.size == 0 || enabled) { forId(id) } else { throw Exception("Cannon disable. There are people with this profile") } }
borboss: create a new observable
It's in terminal state after onError
Also, perhaps utilize Observable.error(Exception(”…”)) instead of throwing an exception manually here.
Resubscribing I believe should do the trick, to “re-execute"
@Paul Woitaschek @alex.hart Thanks! I tried utilizing the Observable.error - but it also did not help ;-( actually the Database starts returning only empty observables if the exception was generated at least once ;-(
println("Enable") Profile.setEnabled(it.funcId, it.enabled).flatMap { Profile.forId(it) }.addTo(controller.updatedProfile)
This is the code - i generate the exception in setEnabled method. After that the binding in the gui prints “Enable” when I hit button, but the database produces only completed observable
Maybe that’s how RxJava works?
RxJava jdbc I mean
Sorry, I didn’t understand the observables correctly.
I got val updatedProfile = CompositeObservable<Profile>()
and if add Profile.setEnabled(it.funcId, it.enabled).flatMap { Profile.forId(it) }.addTo(controller.updatedProfile)
and the setenabled method throws an exception - than the updatedProfile subscription stops working - can I make it work after an exception?
If you want to recover from an exception you might need to use the retry() operator. That might need to be put before the composite observable though