Reaxive.Rx.Impl
Implements the Rx protocols and handles the contract.
Summary
compose(observable, arg2) | Composes the internal action on received events with the given |
compose(observable, fun, acc) | |
disconnect_all(state) | Internal function to disconnect from the sources |
disconnect_source(state, src_id) | Internal function for disconnecting a single source. This function
does not change anything beyond the |
do_action(fun, event, accu, new_accu) | Internal function calculating the new value |
do_subscribe(state, observer) | Internal function for subscribing a new |
emit(impl, event) | Either emits a value or puts it into the queue |
fun(observable, fun, acc \\ []) | This function sets the internal action on received events before the event is propagated to the subscribers. An initial accumulator value can also be provided |
get_sources(observable) | All sources of Rx. Useful for debugging |
handle_call(msg, from, state) | All request-reply calls for setting up the Rx |
handle_cast(msg, state) | Asynchronous callback. Used for processing values and subscription |
handle_event(state, event) | Internal function to handles the various events, in particular disconnects
the source which is sending a |
handle_value(state, value) | Internal function to handle new values, errors or completions. If |
notify(arg1, state) | Internal function to notify subscribers, knows about ignoring notifies |
on_completed(observer, observable) | The last regular message |
on_error(observer, exception) | An error has occured, the pipeline will be aborted |
on_next(observer, value) | Process the next value |
on_subscribe(observable, on_subscribe) | Sets the on_subscribe function, which is called for the first subscription |
source(observable, disposable) | Sets the disposable event sequence |
start() | Starts the Rx Impl. If |
start(name, options) | |
subscribe(observable, observer) | Subscribes a new observer. Returns a function for unsubscribing the observer |
subscribers(observable) | All subscribers of Rx. Useful for debugging |
terminate(reason, state) | Internal callback function at termination for clearing resources |
terminate?(impl) | Internal predicate to check if we terminate ourselves |
unsubscribe(observable, observer) | Unsubscribes an |
Types ↑
rx_propagate :: {:on_next, term} | {:on_error, term} | {:on_completed, nil | pid}
Internal message for propagating events.
reduce_tag :: :cont | :halt | :ignore
Tags for interacting between reduce-function and its reducers. They have the following implications:
:cont
: continue with the iteration and send the current value to subscribers:ignore
: continue the iteration, but do not set anything to subscribers (i.e. ignore the value):halt
: stop the iteration and send the current value to subscribers
reducer :: {reduce_tag, rx_propagate, term}
Return value of reducers
t :: %Reaxive.Rx.Impl{accu: term, action: term, active: term, name: term, on_subscribe: term, options: term, queue: term, sources: term, subscribers: term}
Functions
Composes the internal action on received events with the given fun
. The
initial function to compose with is the identity function.
Specs:
- disconnect_source(%Reaxive.Rx.Impl{accu: term, action: term, active: term, name: term, on_subscribe: term, options: term, queue: term, sources: term, subscribers: term}, any) :: %Reaxive.Rx.Impl{accu: term, action: term, active: term, name: term, on_subscribe: term, options: term, queue: term, sources: term, subscribers: term}
Internal function for disconnecting a single source. This function
does not change anything beyond the sources
field, in particular
no decision about inactivating or even stopping the event sequence
is taken.
Specs:
- do_action(nil | (... -> any), rx_propagate, any, any) :: {:halt | :cont, rx_propagate, any, any}
Internal function calculating the new value
Internal function for subscribing a new observer
This function sets the internal action on received events before the event is propagated to the subscribers. An initial accumulator value can also be provided.
Asynchronous callback. Used for processing values and subscription.
Specs:
- handle_event(t, rx_propagate) :: t
Internal function to handles the various events, in particular disconnects
the source which is sending a on_completed
.
Specs:
- handle_value(t, rx_propagate) :: t
Internal function to handle new values, errors or completions. If state.action
is
:nil
, the value is propagated without any modification.
Specs:
- notify({reduce_tag, rx_propagate}, t) :: t
Internal function to notify subscribers, knows about ignoring notifies.
An error has occured, the pipeline will be aborted.
Sets the on_subscribe function, which is called for the first subscription.
Sets the disposable event sequence source
. This is needed for proper unsubscribing
from the source
when terminating the sequence.
Starts the Rx Impl. If auto_stop
is true, the Impl
finishes after completion or
after an error or after unsubscribing the last subscriber.
Specs:
- subscribe(Observable.t, Observer.t) :: {PID, (() -> :ok)}
Subscribes a new observer. Returns a function for unsubscribing the observer.
Fails grafecully with an on_error
message to the observer, if the
observable is not or no longer available. In this case, an do-nothing unsubciption
functions is returned (since no subscription has occured in the first place).
Internal callback function at termination for clearing resources