#
cp.rx.Observable
Observables push values to Observers.
#
API Overview
Functions - API calls offered directly by the extension
is
Constructors - API calls which return an object, typically one that offers API methods
create defer empty firstEmitting fromCoroutine fromFileByLine fromRange fromTable never of replicate throw zip
Methods - API calls which can only be made on an object returned by a constructor
all average buffer catch combineLatest compact concat contains count debounce defaultIfEmpty delay distinct distinctUntilChanged dump elementAt filter finalize find first flatMap flatMapLatest flatten ignoreElements last map max merge min next partition pluck reduce reject retry retryWithDelay sample scan skip skipLast skipUntil skipWhile startWith subscribe sum switch switchIfEmpty take takeLast takeUntil takeWhile tap timeout unpack unwrap with
#
API Documentation
#
Functions
#
is
Signature | cp.rx.Observable.is(thing) -> boolean |
Type | Function |
Description | Checks if the thing is an instance of Observable. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 26 |
#
Constructors
#
create
Signature | cp.rx.Observable.create(onSubscription) -> cp.rx.Observable |
Type | Constructor |
Description | Creates a new Observable. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 39 |
#
defer
Signature | cp.rx.Observable.defer(fn) -> cp.rx.Observable |
Type | Constructor |
Description | Creates an Observable that executes the function to create a new Observable each time an Observer subscribes. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 256 |
#
empty
Signature | cp.rx.Observable.empty() -> cp.rx.Observable |
Type | Constructor |
Description | Returns an Observable that immediately completes without producing a value. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 75 |
#
firstEmitting
Signature | cp.rx.Observable.firstEmitting(...) -> cp.rx.Observer |
Type | Constructor |
Description | Given a set of Observables, produces values from only the first one to produce a value or complete. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 375 |
#
fromCoroutine
Signature | cp.rx.Observable.fromCoroutine(fn, scheduler) -> cp.rx.Observable |
Type | Constructor |
Description | Creates an Observable that produces values when the specified coroutine yields. |
Parameters | |
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 196 |
#
fromFileByLine
Signature | cp.rx.Observable.fromFileByLine(filename) -> cp.rx.Observable |
Type | Constructor |
Description | Creates an Observable that produces values from a file, line by line. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 230 |
#
fromRange
Signature | cp.rx.Observable.fromRange(initial[, limit[, step]]) -> cp.rx.Observable |
Type | Constructor |
Description | Creates an Observable that produces a range of values in a manner similar to a Lua for loop. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 143 |
#
fromTable
Signature | cp.rx.Observable.fromTable(t, iterator, keys) -> cp.rx.Observable |
Type | Constructor |
Description | Creates an Observable that produces values from a table. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 170 |
#
never
Signature | cp.rx.Observable.never() -> cp.rx.Observable |
Type | Constructor |
Description | Returns an Observable that never produces values and never completes. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 90 |
#
of
Signature | cp.rx.Observable.of(...) -> cp.rx.Observable |
Type | Constructor |
Description | Creates an Observable that produces a set of values. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 122 |
#
replicate
Signature | cp.rx.Observable.replicate(value[, count]) -> cp.rx.Observable |
Type | Constructor |
Description | Creates an Observable that repeats a value a specified number of times. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 274 |
#
throw
Signature | cp.rx.Observable.throw(message, ...) -> cp.rx.Observable |
Type | Constructor |
Description | Returns an Observable that immediately produces an error. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 103 |
#
zip
Signature | cp.rx.Observable.zip(...) -> cp.rx.Observable |
Type | Constructor |
Description | Returns an Observable that merges the values produced by the source Observables by grouping them by their index. The first onNext event contains the first value of all of the sources, the second onNext event contains the second value of all of the sources, and so on. onNext is called a number of times equal to the number of values produced by the Observable that produces the fewest number of values. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 2983 |
#
Methods
#
all
Signature | cp.rx.Observable:all(predicate) -> cp.rx.Observable |
Type | Method |
Description | Determine whether all items emitted by an Observable meet some criteria. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 317 |
#
average
Signature | cp.rx.Observable:average() -> cp.rx.Observable |
Type | Method |
Description | Returns an Observable that produces the average of all values produced by the original. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 453 |
#
buffer
Signature | cp.rx.Observable:buffer(size) -> cp.rx.Observable |
Type | Method |
Description | Returns an Observable that buffers values from the original and produces them as multiple values. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 487 |
#
catch
Signature | cp.rx.Observable:catch(handler) -> cp.rx.Observable |
Type | Method |
Description | Returns an Observable that intercepts any errors from the previous and replace them with values produced by a new Observable. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 545 |
#
combineLatest
Signature | cp.rx.Observable:combineLatest(...) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that runs a combinator function on the most recent values from a set of Observables whenever any of them produce a new value. The results of the combinator function are produced by the new Observable . |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 604 |
#
compact
Signature | cp.rx.Observable:compact() -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that produces the values of the first with falsy values removed. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 667 |
#
concat
Signature | cp.rx.Observable:concat(...) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that produces the values produced by all the specified Observables in the order they are specified. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 680 |
#
contains
Signature | cp.rx.Observable:contains(value) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that produces a single boolean value representing whether or not the specified value was produced by the original. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 739 |
#
count
Signature | cp.rx.Observable:count([predicate]) -> cp.rx.Observable |
Type | Method |
Description | Returns an Observable that produces a single value representing the number of values produced by the source value that satisfy an optional predicate. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 800 |
#
debounce
Signature | cp.rx.Observable:debounce(time[, scheduler]) -> cp.rx.Observable |
Type | Method |
Description | Returns an Observable that mirrors the source Observable , except that it drops items emitted by the source that are followed by newer items before a timeout value expires on a specified Scheduler. The timer resets on each emission. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 854 |
#
defaultIfEmpty
Signature | cp.rx.Observable:defaultIfEmpty(...) |
Type | Method |
Description | Returns a new Observable that produces a default set of items if the source Observable produces no values. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 896 |
#
delay
Signature | cp.rx.Observable:delay(time, scheduler) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that produces the values of the original delayed by a time period. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 950 |
#
distinct
Signature | cp.rx.Observable:distinct() -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that produces the values from the original with duplicates removed. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 989 |
#
distinctUntilChanged
Signature | cp.rx.Observable:distinctUntilChanged([comparator]) -> cp.rx.Observable |
Type | Method |
Description | Returns an Observable that only produces values from the original if they are different from the previous value. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1022 |
#
dump
Signature | cp.rx.Observable:dump(name, formatter) |
Type | Method |
Description | Subscribes to this Observable and prints values it produces. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 296 |
#
elementAt
Signature | cp.rx.Observable:elementAt(index) -> cp.rx.Observable |
Type | Method |
Description | Returns an Observable that produces the n th element produced by the source Observable . |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1061 |
#
filter
Signature | cp.rx.Observable:filter(predicate) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that only produces values of the first that satisfy a predicate. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1100 |
#
finalize
Signature | cp.rx.Observable:finalize(handler) -> cp.rx.Observable |
Type | Method |
Description | Returns an Observable that mirrors the source Observable , but will call a specified function when the source terminates on complete or error. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1211 |
#
find
Signature | cp.rx.Observable:find(predicate) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that produces the first value of the original that satisfies a predicate. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1264 |
#
first
Signature | cp.rx.Observable:first() -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that only produces the first result of the original. If no values are produced, an error is thrown. |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1320 |
#
flatMap
Signature | cp.rx.Observable:flatMap(callback) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that transform the items emitted by an Observable into Observables , then flatten the emissions from those into a single Observable . |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1388 |
#
flatMapLatest
Signature | cp.rx.Observable:flatMapLatest([callback]) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that uses a callback to create Observables from the values produced by the source, then produces values from the most recent of these Observables . |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1402 |
#
flatten
Signature | cp.rx.Observable:flatten() |
Type | Method |
Description | Returns a new Observable that subscribes to the Observables produced by the original and produces their values. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1473 |
#
ignoreElements
Signature | cp.rx.Observable:ignoreElements() -> cp.rx.Observable |
Type | Method |
Description | Returns an Observable that terminates when the source terminates but does not produce any elements. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1549 |
#
last
Signature | cp.rx.Observable:last() -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that only produces the last result of the original. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1572 |
#
map
Signature | cp.rx.Observable:map(callback) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that produces the values of the original transformed by a function . |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1607 |
#
max
Signature | cp.rx.Observable:max() -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that produces the maximum value produced by the original. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1659 |
#
merge
Signature | cp.rx.Observable:merge(...) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that produces the values produced by all the specified Observables in the order they are produced. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1672 |
#
min
Signature | cp.rx.Observable:min() -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that produces the minimum value produced by the original. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1685 |
#
next
Signature | cp.rx.Observable:next() -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that produces at most the first result from the original and then completes. Will not send an error if zero values are sent. |
Parameters |
|
Returns |
|
Notes |
|
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1336 |
#
partition
Signature | cp.rx.Observable:partition(predicate) -> cp.rx.Observable, cp.rx.Observable |
Type | Method |
Description | Returns two Observables : one that produces values for which the predicate returns truthy for, and another that produces values for which the predicate returns falsy. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1711 |
#
pluck
Signature | cp.rx.Observable:pluck(...) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that produces values computed by extracting the given keys from the tables produced by the original. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1725 |
#
reduce
Signature | cp.rx.Observable:reduce(accumulator[, seed]) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that produces a single value computed by accumulating the results of running a function on each value produced by the original Observable . |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1758 |
#
reject
Signature | cp.rx.Observable:reject(predicate) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that produces values from the original which do not satisfy a predicate. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1821 |
#
retry
Signature | cp.rx.Observable:retry([count]) -> cp.rx.Observable |
Type | Method |
Description | Returns an Observable that restarts in the event of an error. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1877 |
#
retryWithDelay
Signature | cp.rx.Observable:retryWithDelay(count[, delay[, scheduler]]) -> cp.rx.Observable |
Type | Method |
Description | Returns an Observable that restarts in the event of an error. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1935 |
#
sample
Signature | cp.rx.Observable:sample(sampler) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that produces its most recent value every time the specified observable produces a value. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1999 |
#
scan
Signature | cp.rx.Observable:scan(accumulator, seed) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that produces values computed by accumulating the results of running a function on each value produced by the original Observable . |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 2064 |
#
skip
Signature | cp.rx.Observable:skip([n]) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that skips over a specified number of values produced by the original and produces the rest. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 2125 |
#
skipLast
Signature | cp.rx.Observable:skipLast(count) -> cp.rx.Observable |
Type | Method |
Description | Returns an Observable that omits a specified number of values from the end of the original Observable . |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 2188 |
#
skipUntil
Signature | cp.rx.Observable:skipUntil(other) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that skips over values produced by the original until the specified Observable produces a value. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 2245 |
#
skipWhile
Signature | cp.rx.Observable:skipWhile(predicate) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that skips elements until the predicate returns falsy for one of them. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 2307 |
#
startWith
Signature | cp.rx.Observable:startWith(...) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that produces the specified values followed by all elements produced by the source Observable . |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 2368 |
#
subscribe
Signature | cp.rx.Observable:subscribe(observer [, onError[, onCompleted]]) -> cp.rx.Reference |
Type | Method |
Description | Shorthand for creating an Observer and passing it to this Observable's |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 56 |
#
sum
Signature | cp.rx.Observable:sum() -> cp.rx.Observable |
Type | Method |
Description | Returns an Observable that produces a single value representing the sum of the values produced by the original. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 2385 |
#
switch
Signature | cp.rx.Observable:switch() -> cp.rx.Observable |
Type | Method |
Description | Given an Observable that produces Observables , returns an Observable that produces the values produced by the most recently produced Observable . |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 2398 |
#
switchIfEmpty
Signature | cp.rx.Observable:switchIfEmpty(alternate) -> cp.rx.Observable |
Type | Method |
Description | Switch to an alternate Observable if this one sends an onCompleted without any onNext s. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 1157 |
#
take
Signature | cp.rx.Observable:take([n]) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that only produces the first n results of the original. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 2459 |
#
takeLast
Signature | cp.rx.Observable:takeLast(count) -> cp.rx.Observable |
Type | Method |
Description | Returns an Observable that produces a specified number of elements from the end of a source Observable . |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 2527 |
#
takeUntil
Signature | cp.rx.Observable:takeUntil(other) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that completes when the specified Observable fires. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 2582 |
#
takeWhile
Signature | cp.rx.Observable:takeWhile(predicate) -> cp.rx.Observable |
Type | Method |
Description | Returns a new Observable that produces elements until the predicate returns falsy . |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 2632 |
#
tap
Signature | cp.rx.Observable:tap(onNext[, onError[, onCompleted]]) -> cp.rx.Observable |
Type | Method |
Description | Runs a function each time this Observable has activity. Similar to |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 2694 |
#
timeout
Signature | cp.rx.Observable:timeout(timeInMs, next[, scheduler]) -> cp.rx.Observable |
Type | Method |
Description | Returns an Observable that will emit an error if the specified time is exceded since the most recent next value. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 2764 |
#
unpack
Signature | cp.rx.Observable:unpack() -> cp.rx.Observable |
Type | Method |
Description | Returns an Observable that unpacks the tables produced by the original. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 2859 |
#
unwrap
Signature | cp.rx.Observable:unwrap() -> cp.rx.Observable |
Type | Method |
Description | Returns an Observable that takes any values produced by the original that consist of multiple return values and produces each value individually. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 2872 |
#
with
Signature | cp.rx.Observable:with(...) -> cp.rx.Observable |
Type | Method |
Description | Returns an Observable that produces values from the original along with the most recently produced value from all other specified Observables . Note that only the first argument from each source Observable is used. |
Parameters |
|
Returns |
|
Notes | None |
Examples | None |
Source | src/extensions/cp/rx/Observable.lua line 2902 |