Skip to content

Commit d3ae208

Browse files
committed
Add documentation
Closes gh-3
1 parent 684979c commit d3ae208

File tree

10 files changed

+1958
-0
lines changed

10 files changed

+1958
-0
lines changed

docs/guide/introduction.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GORM Data Services also support returning RxJava 1.x https://reactivex.io/RxJava/1.x/javadoc/rx/Observable.html[rx.Observable] or https://reactivex.io/RxJava/1.x/javadoc/rx/Single.html[rx.Single] types.
2+
3+
NOTE: RxJava 2.x support is planned for a future release

docs/guide/support.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
For support, please use the https://github.com/orgs/graceframework/discussions[Grace Discussions] or open an issue on link:{github}/issues[Github Issues].

docs/guide/toc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
introduction: Introduction
2+
usage: Usage
3+
support: Support

docs/guide/usage.adoc

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
To use the RxJava support you need to ensure that the `grace-datastore-gorm-rx` dependencies is on the classpath by adding the following to `build.gradle`:
2+
3+
[source,groovy,subs="attributes"]
4+
.build.gradle
5+
----
6+
implementation "org.graceframework:grace-datastore-gorm-rx:{version}"
7+
----
8+
9+
For example:
10+
11+
[source,groovy]
12+
----
13+
import rx.*
14+
15+
@Service(Book)
16+
interface BookService {
17+
Single<Book> findOne(String title)
18+
}
19+
----
20+
21+
When a `rx.Single` is used then a single result is returned. To query multiple results use an `rx.Observable` instead:
22+
23+
[source,groovy]
24+
----
25+
import rx.*
26+
27+
@Service(Book)
28+
interface BookService {
29+
Observable<Book> findBooks(String title)
30+
}
31+
----
32+
33+
For regular GORM entities, GORM will by default execute the persistence operation using RxJava's https://reactivex.io/RxJava/1.x/javadoc/rx/schedulers/Schedulers.html#io()[IO Scheduler].
34+
35+
NOTE: For RxGORM entities where the underlying database supports non-blocking access the database driver will schedule the operation accordingly.
36+
37+
You can run the operation on a different scheduler using the `RxSchedule` annotation:
38+
39+
[source,groovy]
40+
----
41+
import rx.*
42+
import grails.gorm.rx.services.RxSchedule
43+
import grails.gorm.services.Service
44+
import rx.schedulers.Schedulers
45+
46+
@Service(Book)
47+
interface BookService {
48+
49+
@RxSchedule(scheduler = { Schedulers.newThread() })
50+
Observable<Book> findBooks(String title)
51+
}
52+
----

0 commit comments

Comments
 (0)