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.
Summary
from(coll, delay) | Enumerates all elements of the given |
generate(rx, prod_fun, abort_fun, delay) | Generates new values by calling |
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
|
generate_with_accu(rx, prod_fun, abort_fun, accu, delay) | Generates new values by calling |
naturals(delay) | Enumerates the naturals number starting with |
ticks(delay) | Sends a tick every |
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
Specs:
- from(Enumerable.t, non_neg_integer) :: generator_fun_t
Enumerates all elements of the given coll
. Sends the next element
after the delay
milliseconds to rx
.
Specs:
- generate(Observer.t, producer_fun_t, aborter_t(u), non_neg_integer) :: u when u: var
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.
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.
Specs:
- generate_with_accu(Observer.t, producer_with_accu_fun_t, aborter_t(u), accu_t, non_neg_integer) :: u when u: var
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.
Specs:
- naturals(non_neg_integer) :: generator_fun_t
Enumerates the naturals number starting with 0
. Sends the
next number after delay
milliseconds to rx
.
Specs:
- ticks(non_neg_integer) :: generator_fun_t
Sends a tick every delay
milliseconds to rx