Skip to content

Commit 5eb1375

Browse files
author
Aaron Tull
committed
Renaming Dyad to Bi. Reworking the example unit test.
1 parent b0004fc commit 5eb1375

28 files changed

+602
-580
lines changed

README.md

+22-22
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,47 @@ subscribers via onNext. This library includes operators and static methods to co
44
and from the various observable arities including the mono-observable as defined in the
55
core RxJava library.
66

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)`
88
method will be called passing a pair of elements.
99

10-
## Creating a DyadObservable
10+
## Creating a BiObservable
1111

1212
### 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
1414
behavior upon subscription is to subscribe to the source mono-observable once to
1515
generate the string representation.
1616

1717
```java
1818
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()});
2020
```
2121

2222
### 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
2424
`==`.
2525

2626
```java
2727
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"));
2929
```
3030

3131
### 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
3333
language combination.
3434

3535
```java
3636
Observable<Movie> movies = movieService.getMovies();
3737
Observable<Language> langs = geo.getAllLanguages();
38-
DyadObservable<Movie, Language> pairs = DyadObservable.product(movies, langs);
38+
BiObservable<Movie, Language> pairs = BiObservable.product(movies, langs);
3939
```
4040
### 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
4242
Language emitted by the `Observable<Language>` returned by the generator function
4343
provided.
4444

4545
```java
4646
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) -> {
4848
List<Languages> langs = subtitleService.getLanguagesForMovie(m);
4949
return from(langs);
5050
});
@@ -53,36 +53,36 @@ DyadObservable<Movie, Language> pairs = DyadObservable.sparseProduct(movies, (Mo
5353
## Usage
5454

5555
### 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.
5858

5959
```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”; })
6161
.filter2((Boolean isAnswer) -> { return isAnswer.equals(“yep”); });
6262
```
6363

6464
### 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.
6666

6767
```java
6868
Observable<Integer> nums = Observable.range(0,99);
6969
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;});
7171
```
7272

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)`
7676
and `map2(Func2)` replace the second.
7777

7878
```java
79-
DyadObservable<String, MyMovieService> pair = DyadObservable.attach(getAllMovies(), MyMovieService())
79+
BiObservable<String, MyMovieService> pair = BiObservable.attach(getAllMovies(), MyMovieService())
8080
.map1((Movie m, MyMovieService service) -> { return service.getSynopsis(m); });
8181
```
8282

8383
### 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
8585
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
8787
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

Comments
 (0)