# 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
  • thing - The thing to check.
Returns
  • true if the thing is an Observable.
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
  • onSubscription - The reference function that produces values.
Returns
  • The new Observable.
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
  • fn - A function that returns an Observable.
Returns
  • The new Observable.
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
  • None
Returns
  • The new Observable.
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
  • The new Observable.
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
  • fn - A coroutine or function to use to generate values. Note that if a coroutine is used, the values it yields will be shared by all subscribed Observers (influenced by the Scheduler), whereas a new coroutine will be created for each Observer when a function is used.
  • scheduler - The scheduler
Returns
  • The new Observable.
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
  • filename - The name of the file used to create the Observable.
Returns
  • The new Observable.
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
  • initial - The first value of the range, or the upper limit if no other arguments are specified.
  • limit - The second value of the range. Defaults to no limit.
  • step - An amount to increment the value by each iteration. Defaults to 1.
Returns
  • The new Observable.
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
  • t - The table used to create the Observable.
  • iterator - An iterator used to iterate the table, e.g. pairs or ipairs. Defaults to pairs.
  • keys - If true, also emit the keys of the table. Defaults to false.
Returns
  • The new Observable.
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
  • None
Returns
  • The new Observable.
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
  • ... - The list of values to send as individual onNext values.
Returns
  • The new Observable.
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
  • value - The value to repeat.
  • count - The number of times to repeat the value. If left unspecified, the value is repeated an infinite number of times.
Returns
  • The new Observable.
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
  • message - The message to send.
  • ... - The additional values to apply to the message, using string.format syntax.
Returns
  • The new Observable.
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
  • ... - The Observables to zip.
Returns
  • The new Observable.
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
  • predicate - The predicate used to evaluate objects. Defaults to the identity.
Returns
  • A new Observable.
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
  • None
Returns
  • The new Observable.
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
  • size - The size of the buffer.
Returns
  • The new Observable.
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
  • handler - An Observable or a function that returns an Observable to replace the source Observable in the event of an error.
Returns
  • The new Observable.
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
  • ... - One or more Observables to combine. A combinator is a function that combines the latest result from each Observable and returns a single value.
Returns
  • The new Observable.
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
  • None
Returns
  • The new Observable.
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
  • ... - The list of Observables to concatenate.
Returns
  • The new Observable.
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
  • value - The value to search for. == is used for equality testing.
Returns
  • The new Observable.
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
  • predicate - The predicate function used to match values.
Returns
  • The new Observable.
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
  • time - The number of milliseconds.
  • scheduler - The scheduler. If not specified, it will use the [defaultScheduler](cp.rx.util#defaultScheduler].
Returns
  • The new Observable.
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
  • ... - Zero or more values to produce if the source completes without emitting anything.
Returns
  • The new Observable.
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
  • time - An amount in milliseconds to delay by, or a function which returns this value.
  • scheduler - The Scheduler to run the Observable on. If not specified, it will use the [defaultScheduler](cp.rx.util#defaultScheduler].
Returns
  • The new Observable.
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
  • None
Returns
  • The new Observable.
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
  • comparator - A function used to compare 2 values. If unspecified, == is used.
Returns
  • The new Observable
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
  • name - Prefixes the printed messages with a name.
  • formatter - A function that formats one or more values to be printed. Defaults to tostring.
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 nth element produced by the source Observable.
Parameters
  • index - The index of the item, with an index of 1 representing the first.
Returns
  • The new Observable.
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
  • predicate - The predicate function used to filter values.
Returns
  • The new Observable.
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
  • handler - The handler function to call when onError/onCompleted occurs.
Returns
  • The new Observable.
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
  • predicate - The predicate function used to find a value.
Returns
  • The new Observable.
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
  • None
Returns
  • The new Observable.
Notes
  • This is similar to [#next], but will throw an error if no onNext signal is sent before onCompleted.
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
  • callback - The function to transform values from the original Observable.
Returns
  • The new Observable.
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
  • callback - The function used to convert values to Observables. Defaults to the identity function.
Returns
  • The new Observable.
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
  • None
Returns
  • The new Observable.
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
  • None
Returns
  • The new Observable.
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
  • None
Returns
  • The new Observable.
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
  • callback - The function to transform values from the original Observable.
Returns
  • The new Observable.
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
  • None
Returns
  • The new Observable.
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
  • ... - One or more Observables to merge.
Returns
  • The new Observable.
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
  • None
Returns
  • The new Observable.
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
  • None
Returns
  • None
Notes
  • This is similar to [#first], but will not throw an error if no onNext signal is sent before onCompleted.
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
  • predicate - The predicate function used to partition the values.
Returns
  • The 'truthy' Observable.
  • The 'falsy' Observable.
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
  • ... - The key to extract from the table. Multiple keys can be specified to recursively pluck values from nested tables.
Returns
  • The new Observable.
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
  • accumulator - Accumulates the values of the original Observable. Will be passed the return value of the last call as the first argument and the current values as the rest of the arguments.
  • seed - An optional value to pass to the accumulator the first time it is run.
Returns
  • The new Observable.
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
  • predicate - The predicate function used to reject values.
Returns
  • The new Observable.
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
  • count - The maximum number of times to retry. If left unspecified, an infinite number of retries will be attempted.
Returns
  • The new Observable.
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
  • count - The maximum number of times to retry. If left unspecified, an infinite number of retries will be attempted.
  • delay - The function returning or a number representing the delay in milliseconds or a function. If left unspecified, defaults to 1000 ms (1 second).
  • scheduler - The Scheduler to use. If not specified, it will use the [defaultScheduler](cp.rx.util#defaultScheduler].
Returns
  • The new Observable.
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
  • sampler - The Observable that is used to sample values from this Observable.
Returns
  • The new Observable.
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
  • accumulator - Accumulates the values of the original Observable. Will be passed the return value of the last call as the first argument and the current values as the rest of the arguments. Each value returned from this function will be emitted by the Observable.
  • seed - A value to pass to the accumulator the first time it is run.
Returns
  • The new Observable.
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
  • n - The number of values to ignore. Defaults to 1.
Returns
  • The new Observable
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
  • count - The number of items to omit from the end.
Returns
  • The new Observable.
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
  • other - The Observable that triggers the production of values.
Returns
  • The new Observable.
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
  • predicate - The predicate function used to continue skipping values.
Returns
  • The new Observable.
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
  • values - The values to produce before the Observable begins producing values normally.
Returns
  • The new Observable.
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 subscription function.
Parameters
  • observer - Either an Observer or a function to be called when the Observable produces a value.
  • onError - A function to be called when the Observable terminates due to an error.
  • onCompleted - A 'function` to be called when the Observable completes normally.
Returns
  • A Reference which can be used to cancel the subscription.
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
  • None
Returns
  • The new Observable.
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
  • None
Returns
  • The new Observable.
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 onNexts.
Parameters
  • alternate - An Observable to switch to if this does not send any onNext values before the onCompleted.
Returns
  • The new Observable.
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
  • n - The number of elements to produce before completing. Defaults to 1.
Returns
  • The new Observable.
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
  • count - The number of elements to produce.
Returns
  • The new Observable.
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
  • other - The Observable that triggers completion of the original.
Returns
  • The new Observable.
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
  • predicate - The predicate function used to continue production of values.
Returns
  • The new Observable.
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 subscribe but does not create a subscription.
Parameters
  • onNext - Run when the Observable produces values.
  • onError - Run when the Observable encounters a problem.
  • onCompleted - Run when the Observable completes.
Returns
  • The new Observable.
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
  • timeInMs - The time in milliseconds to wait before an error is emitted.
  • next - If a string, it will be sent as an error. If an Observable, switch to that Observable instead of sending an error.
  • scheduler - The scheduler to use. If not specified, it will use the [defaultScheduler](cp.rx.util#defaultScheduler].
Returns
  • The new Observable.
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
  • None
Returns
  • The new Observable.
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
  • None
Returns
  • The new Observable.
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
  • ... - The Observables to include the most recent values from.
Returns
  • The new Observable.
Notes None
Examples None
Source src/extensions/cp/rx/Observable.lua line 2902