observables_extended v0.3.5 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.
Delays each produced item by the given interval.
Filters out values that have already been produced by any given observable.
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.
Returns the last emitted value of the Observable.
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.
Filters out values that are equal to the most recently produced value.
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.
Convert an Observable that emits Observables into a single Observable that emits the items emitted by the most-recently-emitted of those Observables. Emits the last value of the new Observable if not nil upon switching.
Takes the n first element of the observable, and then stops.
Takes two Observables and a 'switch' Observable. Emits the values of the first Observable until the switch Observable emits a value, at which point the resulting Observable switches and only emits values from the second Observable.
Takes two Observables and a 'switch' Observable. Emits the values of the first Observable until the switch Observable emits a value, at which point the resulting Observable switches and only emits values from the second Observable. Emits the last value of the second Observable if not nil upon switching.
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
buffer(arg, size) View Source
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
chunk(arg, interval) View Source
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
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
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.
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
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$ --->
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
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.
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
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
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
count(obs, default \\ 0) View Source
delay(arg, interval) View Source
Delays each produced item by the given interval.
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 as a comparator if none is given.
Any supplied comparator function should take 2 arguments,
and return a boolean, indicating equality.
More information: http://reactivex.io/documentation/operators/distinct.html
each(arg, f) View Source
Same as map, but returns the original value. Typically used for side effects.
More information: http://reactivex.io/documentation/operators/subscribe.html
filter(arg, f) View Source
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
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(producer) View Source
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
inspect(arg) View Source
Same as the print/1 function, but uses inspect to print instead of puts.
last(arg) View Source
Returns the last emitted value of the Observable.
map(arg, f) View Source
Applies a given function to each value produces by the dependency observable.
More information: http://reactivex.io/documentation/operators/map.html
merge(list) View Source
Combine a list of observables into a single observable that will emit the events produced by the inputs in a fifo fashion.
merge(arg1, arg2) View Source
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
novel(arg, f \\ fn x, y -> x == y end) View Source
Filters out values that are equal to the most recently produced value.
Uses the default ==
function as a comparator if none is given.
Any supplied comparator function should take 2 arguments,
and return a boolean, indicating equality.
print(arg) View Source
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(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(f, opts \\ []) View Source
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
rotate(obss) View Source
Combine a list of observables into a single observable that will emit the events produced by the inputs in a round-robin fashion.
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
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
switch(initial_obs \\ nil, arg) View Source
Convert an Observable that emits Observables into a single Observable that emits the items emitted by the most-recently-emitted of those Observables.
It is possible to supply an Observable as the start Observable.
More information: http://reactivex.io/documentation/operators/switch.html
switch_repeat(initial_obs \\ nil, arg) View Source
Convert an Observable that emits Observables into a single Observable that emits the items emitted by the most-recently-emitted of those Observables. Emits the last value of the new Observable if not nil upon switching.
It is possible to supply an initial Observable as the first argument.
More information: http://reactivex.io/documentation/operators/switch.html
take(arg, n) View Source
Takes the n first element of the observable, and then stops.
More information: http://reactivex.io/documentation/operators/take.html
until(obs1, obs2, obs_switch) View Source
Takes two Observables and a 'switch' Observable. Emits the values of the first Observable until the switch Observable emits a value, at which point the resulting Observable switches and only emits values from the second Observable.
until_repeat(obs1, obs2, obs_switch) View Source
Takes two Observables and a 'switch' Observable. Emits the values of the first Observable until the switch Observable emits a value, at which point the resulting Observable switches and only emits values from the second Observable. Emits the last value of the second Observable if not nil upon switching.
unzip(obs) View Source
Unzip an observable whose values are tuples {left, right}.
zip(l, r) View Source
Combine the emissions of multiple Observables together and emit single items for each combination.
More information: http://reactivex.io/documentation/operators/zip.html
zip_n(obss) View Source
Combine the emissions of a list of observables together and emit single items for each combination.
zip_var(obs, obss) View Source
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.