Netflix/RxJava — pull request #770 by benjchristensen (2014-01-21 05:21:19+00:00)
Title: Bind Operator

Implementation of `bind` operator along with new `create` and `subscribe` methods and several reimplemented operators: `fromIterable`, `toList`, `toSortedList`, `map`, `cast`, `timestamp`, `merge`, `flatMap`, `mergeMap`, `groupBy`, `parallel`.

The `bind` signature is:

```java
public Observable bind(final Func1, Operator> bind)
```

The new `Operator` class signature is:

```java
public abstract class Operator implements Observer, Subscription
```

The `create` method now looks like:

```java
public final static Observable create(final Action1> f)
```

A new `subscribe` signature is:

```java
public final void subscribe(Operator o)
```

The use of these three new methods allows for chaining operators together and supporting unsubscription on both synchronous and asynchronous sources.

##### Status and Plan

- I have temporarily disabled Scala and Kotlin builds until they are fixed.
- The Groovy module has been retrofitted with an extension module to intercept and disambiguate the new `create` method from the deprecated one.
- I have not yet tested Clojure or JRuby
- I am pretty certain I have the generics wrong on `OperatorMerge` so am using it in non-typesafe manner right now

This design has been reviewed with several people on Github and in person. Besides resolving the items listed above, my intention is as follows:

- invite feedback and review on this pull request in the next 12-24 hours
- merge into trunk if nothing major comes up
- work towards resolving issues with the language adaptors and polishing any rough edges of the new changes
- finalize `bind` signatures
- consider deprecating or eliminating `CurrentThreadScheduler` (if it needs to exist at all, perhaps rename to `TrampolineScheduler` to remove confusion between `Immediate` and `CurrentThread`)
- release as 0.17.0 (along with some unrelated `Scheduler` changes)
- continue working in the future migrating operators to this new design

See https://github.com/Netflix/RxJava/issues/746 for background on the proposal, reasons and design discussion.