caolan/highland — pull request #175 by vqvu (2014-11-29 03:55:01+00:00)
Title: Fix consume and redirect.

Reimplement the stream backend to fix redirect. The old way of doing things was too hard to get right (as evidenced by the number of bugs that we have related to redirect).

This involves:
- Totally reimplementing stream redirection.
- Reimplementing `consume`, `pull`, `fork`, and `resume`.
- `debounce`, `throttle`, and `latest` were reimplemented using the public interface instead of private methods.

Possible backward incompatibility concerns;
1. You can no longer call `fork` on a stream that has been `consumed`.
2. The stream no longer pauses if `next` isn't synchronously called in `consume`, since this is no longer necessary to signal (lack of) demand to the source.
3. The callback for the stream generator and `consume` is guaranteed not to be called a second time until `next` is called. Before, you just needed to `resume` the stream.

Only (1) is even a potential problem I think. Strictly speaking, the API never said you were allowed to `fork` after `consume`, especially since you were never allowed to `consume` after `fork`.

Fixes:
- #41
- #141
- #142
- #173

Comments welcome.