nextThen is the callback-oriented interface to work with channel objects. Provide the channel callback functions to receive the next element, error, and closing signals; your callbacks will be stored in a queue and called when values are available.

nextThen(x, onNext, onError, onClose, ...)

subscribe(x, ...)



A channel object


For nextThen, a function to be called with the next emitted value. For subscribe, a function to be called with each emitted value until the stream finishes.


Function to be called if channel stops with an error. Note that if you call nextThen multiple times to register multile callbacks, only the first will receive onError; the rest will be called with onClose.


Function to be called if the channel finishes normally.




subscribe is similar to nextThen except that your onNext will be called for each value the channel emits. It is just implemented in terms of nextThen, with a callback that re-registers itself.