Reaxive.Generator

This module collects functions for generating a sequence of events. These generators are always the roots of the event sequence network, they do not subscribe to other sequences. However, often they use other data sources such a stream, an IO connection or the like.

Generators have the important feature of being canceable. This means that their generation process can be canceled from the outside. This is important for freeing up any other resources used the generator while producing new events.

Source

Summary

from(coll, delay)

Enumerates all elements of the given coll. Sends the next element after the delay milliseconds to rx

generate(rx, prod_fun, abort_fun, delay)

Generates new values by calling prod_fun and sending them to rx. If canceled (by receiving :cancel), the abort_fun is called. Between two events a delay, measured in milliseconds, takes place

generate_stream(rx, stream, delay)

Generates values from a stream. Expect that the stream only contains proper elments, no errors can occur. After the end of the stream, an on_complete message is send

generate_with_accu(rx, prod_fun, abort_fun, accu, delay)

Generates new values by calling prod_fun and sending them to rx. If canceled (by receiving :cancel), the abort_fun is called. Between two events a delay, measured in milliseconds, takes place

naturals(delay)

Enumerates the naturals number starting with 0. Sends the next number after delay milliseconds to rx

ticks(delay)

Sends a tick every delay milliseconds to rx

Types

accu_t :: any

generator_fun_t :: (Observable.t -> any)

Generator function to be used by Reaxive.Rx.delayed_start

rx_propagate :: {:on_next, any} | {:on_error, any} | {:on_completed, pid}

Return value of producer functions for generators

producer_fun_t :: (() -> rx_propagate)

Producer function without accu

producer_with_accu_fun_t :: (accu_t -> {accu_t, rx_propagate})

Producer function with accu

aborter_t(u) :: (() -> u)

The type of the abort function of a generator

Functions

from(coll, delay)

Specs:

Enumerates all elements of the given coll. Sends the next element after the delay milliseconds to rx.

Source
generate(rx, prod_fun, abort_fun, delay)

Specs:

Generates new values by calling prod_fun and sending them to rx. If canceled (by receiving :cancel), the abort_fun is called. Between two events a delay, measured in milliseconds, takes place.

This function assumes an infinite generator. There is no means for finishing the generator except for canceling.

Source
generate_stream(rx, stream, delay)

Generates values from a stream. Expect that the stream only contains proper elments, no errors can occur. After the end of the stream, an on_complete message is send.

Source
generate_with_accu(rx, prod_fun, abort_fun, accu, delay)

Specs:

Generates new values by calling prod_fun and sending them to rx. If canceled (by receiving :cancel), the abort_fun is called. Between two events a delay, measured in milliseconds, takes place.

This function assumes an infinite generator. There is no means for finishing the generator except for canceling.

Source
naturals(delay)

Specs:

Enumerates the naturals number starting with 0. Sends the next number after delay milliseconds to rx.

Source
ticks(delay)

Specs:

Sends a tick every delay milliseconds to rx

Source