Learn R Programming

async (version 0.3.2)

nextThen: Receive values from channels by callback.

Description

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.

Usage

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

subscribe(x, ...)

Arguments

x

A channel object

onNext

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.

onError

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.

onClose

Function to be called if the channel finishes normally.

...

Undocumented.

Details

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.