File tree Expand file tree Collapse file tree 1 file changed +20
-12
lines changed
language-adaptors/rxjava-groovy/src/examples/groovy/rx/lang/groovy/examples Expand file tree Collapse file tree 1 file changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -108,19 +108,27 @@ Observable getVideoGridForDisplay(userId) {
108
108
Observable<VideoList > getListOfLists (userId ) {
109
109
return Observable . create({ observer ->
110
110
BooleanSubscription subscription = new BooleanSubscription ();
111
- // this will happen on a separate thread as it requires a network call
112
- executor. execute({
113
- // simulate network latency
114
- Thread . sleep(180 );
115
- for (i in 0 .. 15 ) {
116
- if (subscription. isUnsubscribed()) {
117
- break ;
111
+ try {
112
+ // this will happen on a separate thread as it requires a network call
113
+ executor. execute({
114
+ // simulate network latency
115
+ Thread . sleep(180 );
116
+ for (i in 0 .. 15 ) {
117
+ if (subscription. isUnsubscribed()) {
118
+ break ;
119
+ }
120
+ try {
121
+ // println("****** emitting list: " + i)
122
+ observer. onNext(new VideoList (i))
123
+ }catch (Exception e) {
124
+ observer. onError(e);
125
+ }
118
126
}
119
- // println("****** emitting list: " + i)
120
- observer . onNext( new VideoList (i) )
121
- }
122
- observer. onCompleted( );
123
- })
127
+ observer . onCompleted();
128
+ } )
129
+ } catch ( Exception e) {
130
+ observer. onError(e );
131
+ }
124
132
return subscription;
125
133
})
126
134
}
You can’t perform that action at this time.
0 commit comments