@@ -4,47 +4,47 @@ subscribers via onNext. This library includes operators and static methods to co
4
4
and from the various observable arities including the mono-observable as defined in the
5
5
core RxJava library.
6
6
7
- When a ` DyadObservable ` is subscribed to by a ` DyadSubscriber ` the ` onNext(T0, T1) `
7
+ When a ` BiObservable ` is subscribed to by a ` BiSubscriber ` the ` onNext(T0, T1) `
8
8
method will be called passing a pair of elements.
9
9
10
- ## Creating a DyadObservable
10
+ ## Creating a BiObservable
11
11
12
12
### Generate
13
- Emits dyads of an ` Integer ` and its ` String ` representation. The DyadObservable 's
13
+ Emits bi-values of an ` Integer ` and its ` String ` representation. The BiObservable 's
14
14
behavior upon subscription is to subscribe to the source mono-observable once to
15
15
generate the string representation.
16
16
17
17
``` java
18
18
Observable<Integer > intRange = Observable . range(0 ,99 );
19
- DyadObservable <Integer , String > pairs = DyadObservable . generate(intRange, (Integer i) - > {return i. toString()});
19
+ BiObservable <Integer , String > pairs = BiObservable . generate(intRange, (Integer i) - > {return i. toString()});
20
20
```
21
21
22
22
### Attach
23
- Emits dyads of an ` Integer ` and a ` java.io.File ` where all dyad 's second element are
23
+ Emits bi-values of an ` Integer ` and a ` java.io.File ` where all bi-value 's second element are
24
24
` == ` .
25
25
26
26
``` java
27
27
Observable<Integer > intRange = Observable . range(0 ,99 );
28
- DyadObservable <Integer , File > withFile = DyadObservable . attach(intRange, new File (" log.txt" ));
28
+ BiObservable <Integer , File > withFile = BiObservable . attach(intRange, new File (" log.txt" ));
29
29
```
30
30
31
31
### Product
32
- Emits dyads of a ` Movie ` and a ` Language ` . There will be 1 dyad for each movie and
32
+ Emits bi-values of a ` Movie ` and a ` Language ` . There will be 1 bi-value for each movie and
33
33
language combination.
34
34
35
35
``` java
36
36
Observable<Movie > movies = movieService. getMovies();
37
37
Observable<Language > langs = geo. getAllLanguages();
38
- DyadObservable <Movie , Language > pairs = DyadObservable . product(movies, langs);
38
+ BiObservable <Movie , Language > pairs = BiObservable . product(movies, langs);
39
39
```
40
40
### Sparse Product
41
- Emits dyads of a ` Movie ` and a ` Language ` . Each movie will have one dyad for each
41
+ Emits bi-values of a ` Movie ` and a ` Language ` . Each movie will have one bi-value for each
42
42
Language emitted by the ` Observable<Language> ` returned by the generator function
43
43
provided.
44
44
45
45
``` java
46
46
Observable<Movie > movies = movieService. getMovies();
47
- DyadObservable <Movie , Language > pairs = DyadObservable . sparseProduct(movies, (Movie m) - > {
47
+ BiObservable <Movie , Language > pairs = BiObservable . sparseProduct(movies, (Movie m) - > {
48
48
List<Languages > langs = subtitleService. getLanguagesForMovie(m);
49
49
return from(langs);
50
50
});
@@ -53,36 +53,36 @@ DyadObservable<Movie, Language> pairs = DyadObservable.sparseProduct(movies, (Mo
53
53
## Usage
54
54
55
55
### Filtering
56
- A filter predicate can be written for the first, second, or both elements of a dyad . The
57
- following example filters all dyads but one based on the second element.
56
+ A filter predicate can be written for the first, second, or both elements of a bi-value . The
57
+ following example filters all bi-values but one based on the second element.
58
58
59
59
``` java
60
- DyadObservable . generate(Observable . range(0 ,100 ), (Integer i) - > { return i == 42 ? “yep” : “nope”; })
60
+ BiObservable . generate(Observable . range(0 ,100 ), (Integer i) - > { return i == 42 ? “yep” : “nope”; })
61
61
.filter2((Boolean isAnswer) - > { return isAnswer. equals(“yep”); });
62
62
```
63
63
64
64
### Mono-Mapping
65
- Dyads can be mapped back to a single valued ` Observable ` using the ` bimap ` operator.
65
+ Bi-values can be mapped back to a single valued ` Observable ` using the ` bimap ` operator.
66
66
67
67
``` java
68
68
Observable<Integer > nums = Observable . range(0 ,99 );
69
69
Observable<Integer > factorsOf3 = nums. map((Integer i) - > {return i * 3 ;});
70
- Observable<Integer > factorsOf5 = DyadObservable . attach(nums, 5 ). biMap((Integer i, Integer factor) - > {return i * factor;});
70
+ Observable<Integer > factorsOf5 = BiObservable . attach(nums, 5 ). biMap((Integer i, Integer factor) - > {return i * factor;});
71
71
```
72
72
73
- ### Dyadic -Mapping
74
- You can replace a single element of a dyad at a time. The ` map1(Func1) ` and
75
- ` map1(Func2) ` overloads replace the first element of the dyads , while the ` map2(Func1) `
73
+ ### Bi -Mapping
74
+ You can replace a single element of a bi-value at a time. The ` map1(Func1) ` and
75
+ ` map1(Func2) ` overloads replace the first element of the bi-values , while the ` map2(Func1) `
76
76
and ` map2(Func2) ` replace the second.
77
77
78
78
``` java
79
- DyadObservable <String , MyMovieService > pair = DyadObservable . attach(getAllMovies(), MyMovieService())
79
+ BiObservable <String , MyMovieService > pair = BiObservable . attach(getAllMovies(), MyMovieService())
80
80
.map1((Movie m, MyMovieService service) - > { return service. getSynopsis(m); });
81
81
```
82
82
83
83
### Scanning
84
- The ` scan1 ` and ` scan2 ` operators will replace the first or second element of a dyad
84
+ The ` scan1 ` and ` scan2 ` operators will replace the first or second element of a bi-value
85
85
respectively with the result of the provided accumulator function. This will preserve
86
- the second element for each dyad . Note that scanning over a dyad cannot emit the
86
+ the second element for each bi-value . Note that scanning over a bi-value cannot emit the
87
87
provided seed value as the pre-computation onNext because there is no second element of
88
- the dyad to emit.
88
+ the bi-value to emit.
0 commit comments