observables_extended v0.2.0 Observables.Obs View Source

Link to this section Summary

Functions

Periodically gather items emitted by an Observable into bundles of size size and emit these bundles rather than emitting the items one at a time.

Chunks items produces by the observable together bounded in time. As soon as the set delay has been passed, the observable emits an enumerable with the elements gathered up to that point. Does not emit the empty list.

Given two observables, merges them together and always merges the last result of on of both, and reuses the last value from the other.

Generalization of Combinelatest2 to an unspecified number n of observees. Takes a list of observables and merges them together by combining the newly received value of an observable with the latest values from the others.

Generalization of combinelatestsilent to n observables to 'combine latest' and m observables to zip.

Generalization of combinelatestsilent_silent_buffered to n observables to 'combine latest' and m observables to zip.

Generalization of combinelatestsilent_buffered_propagating to n observables to 'combine latest' and m observables to zip.

Generalization of Combinelatestn to a number of observables that can be subject to change. Takes a list of initial observables and one higher order observable. Values of the latter are tuples {observable, initial_value}. We add these observables as new incoming dependencies and initialize them with the given value.. At any given moment, we combine the newly received value of an observable with the latest values of other current observables.

Given two observables, merges them together by zipping the values of one with the latest value from the other. The zip observable will trigger an update if there is a value for the combine observable, otherwise the zip value will be lost. The combine observable will never trigger the production of a new value, but will instead update 'silently'.

Given two observables, merges them together by zipping the values of one with the latest value from the other. The zip observable will trigger an update if there is a value for the combine observable, otherwise it will add this value to a buffer. When updating, we always take the first value of the zip buffer. The combine observable will never trigger an update, but will instead update 'silently' by replacing its latest value.

Given two observables, merges them together by zipping the values of one with the latest value from the other. The zip observable will trigger an update if there is a value for the combine observable, otherwise it will add this value to a buffer. The combine observable will in steady state not trigger an update, but will instead update 'silently' by replacing its latest value. If however a value for the combine observable is received for the first time in the presence of a zip buffer, We will combine the whole zip buffer at once with this combine value.

Filters out values that have already been produced by any given observable. Uses the default == function if none is given.

Same as map, but returns the original value. Typically used for side effects.

Filters out the values that do not satisfy the given predicate.

Takes an enumerable and turns it into an observable that produces a value for each value of the enumerable. If the enum is consumed, returns done.

from_pid/1 can be considered to be a subject. Any process that implements the GenObservable interface can be used as a subject, actually. Example: Spawn a subject using the Subject module. {:ok, pid1} = GenObservable.spawn_supervised(Subject, 0)

Same as the print/1 function, but uses inspect to print instead of puts.

Applies a given function to each value produces by the dependency observable.

Combine a list of observables into a single observable that will emit the events produced by the inputs in a fifo fashion.

Combine two observables into a single observable that will emit the events produced by the inputs in a fifo fashion.

Prints out the values produces by this observable. Keep in mind that this only works for values that are actually printable. If not sure, use inspect/1 instead.

Range creates an observable that will start at the given integer and run until the last integer. If no second argument is given, the stream is infinite. One can use :infinity as the end for an infinite stream (see: https://elixirforum.com/t/infinity-in-elixir-erlang/7396)

repeat takes a function as argument and an optional interval. The function will be repeatedly executed, and the result will be emitted as an event.

Combine a list of observables into a single observable that will emit the events produced by the inputs in a round-robin fashion.

Applies a given procedure to an observable's value, and its previous result. Works in the same way as the Enum.scan function

Prepends any observable with a list of values provided here in the form of a list.

Convert an Observable that emits Observables into a single Observable that emits the items emitted by the most-recently-emitted of those Observables.

Takes the n first element of the observable, and then stops.

Unzip an observable whose values are tuples {left, right}.

Combine the emissions of multiple Observables together and emit single items for each combination.

Combine the emissions of a list of observables together and emit single items for each combination.

Combine the emissions of a list of observables together and emit single items for each combination.

Link to this section Functions

Periodically gather items emitted by an Observable into bundles of size size and emit these bundles rather than emitting the items one at a time.

Source: http://reactivex.io/documentation/operators/buffer.html

Chunks items produces by the observable together bounded in time. As soon as the set delay has been passed, the observable emits an enumerable with the elements gathered up to that point. Does not emit the empty list.

Works in the same vein as the buffer observable, but that one is bound by number, and not by time.

Source: http://reactivex.io/documentation/operators/buffer.html

Link to this function

combinelatest(l, r, opts \\ [left: nil, right: nil]) View Source

Given two observables, merges them together and always merges the last result of on of both, and reuses the last value from the other.

E.g.

1 -> 2 ------> 3
A -----> B ------> C 
=
1A --> 2A -> 2B -> 3B -> 3C

More information: http://reactivex.io/documentation/operators/combinelatest.html

Link to this function

combinelatest_n(obss, opts \\ [inits: nil]) View Source

Generalization of Combinelatest2 to an unspecified number n of observees. Takes a list of observables and merges them together by combining the newly received value of an observable with the latest values from the others.

Link to this function

combinelatest_n_zip_m(cobss, zobss, opts \\ [inits: nil]) View Source

Generalization of combinelatestsilent to n observables to 'combine latest' and m observables to zip.

E.g.

c1: -------------> 1 ----------> 2 ------> 3 -->
c2: ------> A --------> B -------------------> C 
z1: a -------> b----------- c --------> d ----->
z2: --> @ ------> $ ----> % -----> & ---------->
=
r:  ------------------------>1Bc%------->2Bd& ->

More information: http://reactivex.io/documentation/operators/combinelatest.html

Link to this function

combinelatest_n_zip_m_buffered(cobss, zobss, opts \\ [init: nil]) View Source

Generalization of combinelatestsilent_silent_buffered to n observables to 'combine latest' and m observables to zip.

E.g.

c1: -------------> 1 --------------> 2 --------------------> 3
c2: ------> A --------> B --------------------> C ----------->
z1: a -------> b-----------------> c --------------> d ------>
z2: --> @ ------> $ ------> % -------------> & -------------->
=
r:  -----------------------------> 1Ba@ -----------> 2Cb$ --->
Link to this function

combinelatest_n_zip_m_buffered_propagating(cobss, zobss, opts \\ [init: nil]) View Source

Generalization of combinelatestsilent_buffered_propagating to n observables to 'combine latest' and m observables to zip.

E.g.

c1: ----------------> 1 ------------------------> 2 ---------------> 3
c2: ------> A ------------------> B --------------------> C --------->
z1: a -------> b-------------------------> c --------------> d ------>
z2: --> @ ------> $ ---------------> % -------------> & ------------->
=
r:  -----------------> 1Aa@ 1Ab$ --------> 1Bc% -----------> 2Cd& --->

More information: http://reactivex.io/documentation/operators/combinelatest.html

Link to this function

combinelatest_var(obs, obss, opts \\ [inits: nil]) View Source

Generalization of Combinelatestn to a number of observables that can be subject to change. Takes a list of initial observables and one higher order observable. Values of the latter are tuples {observable, initial_value}. We add these observables as new incoming dependencies and initialize them with the given value.. At any given moment, we combine the newly received value of an observable with the latest values of other current observables.

Link to this function

combinelatestsilent(cobs, zobs, opts \\ [init: nil, silent: :right]) View Source

Given two observables, merges them together by zipping the values of one with the latest value from the other. The zip observable will trigger an update if there is a value for the combine observable, otherwise the zip value will be lost. The combine observable will never trigger the production of a new value, but will instead update 'silently'.

E.g.

1 ---> 2 -------> 3 ------>
A -------> B -----------> C 
=
1A ---> 2A -----> 3B ----->

More information: http://reactivex.io/documentation/operators/combinelatest.html

Link to this function

combinelatestsilent_buffered(cobs, zobs, opts \\ [init: nil]) View Source

Given two observables, merges them together by zipping the values of one with the latest value from the other. The zip observable will trigger an update if there is a value for the combine observable, otherwise it will add this value to a buffer. When updating, we always take the first value of the zip buffer. The combine observable will never trigger an update, but will instead update 'silently' by replacing its latest value.

E.g.

1 -> 2 ------> 3 ---> 4
-----> A ------> C --->
=
-------------> 1A -> 2C
Link to this function

combinelatestsilent_buffered_propagating(cobs, zobs, opts \\ [init: nil]) View Source

Given two observables, merges them together by zipping the values of one with the latest value from the other. The zip observable will trigger an update if there is a value for the combine observable, otherwise it will add this value to a buffer. The combine observable will in steady state not trigger an update, but will instead update 'silently' by replacing its latest value. If however a value for the combine observable is received for the first time in the presence of a zip buffer, We will combine the whole zip buffer at once with this combine value.

E.g.

1 -> 2 ------> 3 ---> 4
-----> A --> C -------->
=
-----> 1A-2A --> 3C -> 4C
Link to this function

count(obs, default \\ 0) View Source

Link to this function

distinct(arg, f \\ fn x, y -> x == y end) View Source

Filters out values that have already been produced by any given observable. Uses the default == function if none is given.

The expected function should take 2 arguments, and return a boolean indication the equality.

More information: http://reactivex.io/documentation/operators/distinct.html

Same as map, but returns the original value. Typically used for side effects.

More information: http://reactivex.io/documentation/operators/subscribe.html

Filters out the values that do not satisfy the given predicate.

The expection function should take 1 arguments and return a boolean value. True if the value should be produced, false if the value should be discarded.

More information: http://reactivex.io/documentation/operators/filter.html

Link to this function

from_enum(coll, delay \\ 1000) View Source

Takes an enumerable and turns it into an observable that produces a value for each value of the enumerable. If the enum is consumed, returns done.

More information: http://reactivex.io/documentation/operators/from.html

from_pid/1 can be considered to be a subject. Any process that implements the GenObservable interface can be used as a subject, actually. Example: Spawn a subject using the Subject module. {:ok, pid1} = GenObservable.spawn_supervised(Subject, 0)

Print out each value that the subject produces.

Obs.from_pid(pid1)
|> Obs.print()

Send an event to the subject. GenObservable.send_event(pid1, :value)

More information: http://reactivex.io/documentation/subject.html

Same as the print/1 function, but uses inspect to print instead of puts.

Applies a given function to each value produces by the dependency observable.

More information: http://reactivex.io/documentation/operators/map.html

Combine a list of observables into a single observable that will emit the events produced by the inputs in a fifo fashion.

Combine two observables into a single observable that will emit the events produced by the inputs in a fifo fashion.

More information: http://reactivex.io/documentation/operators/merge.html

Prints out the values produces by this observable. Keep in mind that this only works for values that are actually printable. If not sure, use inspect/1 instead.

Link to this function

range(first, last, delay \\ 1000) View Source

Range creates an observable that will start at the given integer and run until the last integer. If no second argument is given, the stream is infinite. One can use :infinity as the end for an infinite stream (see: https://elixirforum.com/t/infinity-in-elixir-erlang/7396)

More information: http://reactivex.io/documentation/operators/range.html

repeat takes a function as argument and an optional interval. The function will be repeatedly executed, and the result will be emitted as an event.

More information: http://reactivex.io/documentation/operators/repeat.html

Combine a list of observables into a single observable that will emit the events produced by the inputs in a round-robin fashion.

Link to this function

scan(arg, f, default \\ nil) View Source

Applies a given procedure to an observable's value, and its previous result. Works in the same way as the Enum.scan function:

Enum.scan(1..10, fn(x,y) -> x + y end) => [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]

More information: http://reactivex.io/documentation/operators/scan.html

Link to this function

starts_with(arg, start_vs) View Source

Prepends any observable with a list of values provided here in the form of a list.

More information: http://reactivex.io/documentation/operators/startwith.html

Convert an Observable that emits Observables into a single Observable that emits the items emitted by the most-recently-emitted of those Observables.

More information: http://reactivex.io/documentation/operators/switch.html

Takes the n first element of the observable, and then stops.

More information: http://reactivex.io/documentation/operators/take.html

Unzip an observable whose values are tuples {left, right}.

Combine the emissions of multiple Observables together and emit single items for each combination.

More information: http://reactivex.io/documentation/operators/zip.html

Combine the emissions of a list of observables together and emit single items for each combination.

Combine the emissions of a list of observables together and emit single items for each combination.

Takes an extra higher order observable carrying new observables to zip with.