forked from ReactiveX/RxJava
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathexamples.txt
More file actions
47 lines (36 loc) · 1.56 KB
/
Copy pathexamples.txt
File metadata and controls
47 lines (36 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Here's the example source of Observable (heavily elided):
public class rx.Observable {
public static <T> Observable<T> create(Func1<Observer<T>, Subscription> func) {
return new Observable<T>(func);
}
public static <T> Observable<T> create(Object func) {
...
}
public static <T> Observable<T> take(final Observable<T> items, final int num) {
return create(OperationTake.take(items, num));
}
public static <T> Observable<T> takeWhile(final Observable<T> items, Func1<T, Boolean> predicate) {
return create(OperationTakeWhile.takeWhile(items, predicate));
}
public Observable<T> filter(Func1<T, Boolean> predicate) {
return filter(this, predicate);
}
public static <T> Observable<T> filter(Observable<T> that, Func1<T, Boolean> predicate) {
return create(OperationFilter.filter(that, predicate));
}
}
Groovy-friendly version adds:
public class rx.Observable {
public static <T> rx.Observable<T> create(groovy.lang.Closure func) {
return create(new GroovyFunctionAdaptor(func));
}
public static <T> rx.Observable<T> takeWhile(final Observable<T> items, groovy.lang.Closure predicate) {
return takeWhile(items, new GroovyFunctionAdaptor(predicate));
}
public rx.Observable<T> filter(groovy.lang.Closure predicate) {
return filter(new GroovyFunctionAdaptor(predicate));
}
public static <T> rxObservable<T> filter(Observable<T> that, groovy.lang.Closure predicate) {
return filter(that, new GroovyFunctionAdaptor(predicate));
}
}