# cp.rx.Subject

Subjects function both as an Observer and as an Observable. Subjects inherit all Observable functions, including subscribe. Values can also be pushed to the Subject, which will be broadcasted to any subscribed Observers.


# API Overview

Constructors - API calls which return an object, typically one that offers API methods

  • create

Methods - API calls which can only be made on an object returned by a constructor

  • onCompleted
  • onError
  • onNext
  • subscribe

# API Documentation

# Constructors

# create

Signature cp.rx.Subject.create() -> cp.rx.Subject
Type Constructor
Description Creates a new Subject.
Parameters
  • None
Returns
  • The Subject.
Notes None
Examples None
Source src/extensions/cp/rx/Subject.lua line 21

# Methods

# onCompleted

Signature cp.rx.Subject:onCompleted() -> nil
Type Method
Description Signal to all Observers that the Subject will not produce any more values.
Parameters
  • None
Returns
  • None
Notes None
Examples None
Source src/extensions/cp/rx/Subject.lua line 127

# onError

Signature cp.rx.Subject:onError(message) -> nil
Type Method
Description Signal to all Observers that an error has occurred.
Parameters
  • message - A string describing what went wrong.
Returns
  • None
Notes None
Examples None
Source src/extensions/cp/rx/Subject.lua line 105

# onNext

Signature cp.rx.Subject:onNext(...) -> nil
Type Method
Description Pushes zero or more values to the Subject. They will be broadcasted to all Observers.
Parameters
  • ... - The values to send.
Returns
  • None
Notes None
Examples None
Source src/extensions/cp/rx/Subject.lua line 86

# subscribe

Signature cp.rx.Subject:subscribe(observer[, onError[, onCompleted]]) -> cp.rx.Reference
Type Method
Description Creates a new Observer and attaches it to the Subject.
Parameters
  • observer - Either an Observer, or a function called when the Subject produces a value.
  • onError - A function called when the Subject terminates due to an error.
  • onCompleted - A function called when the Subject completes normally.
Returns
Notes None
Examples None
Source src/extensions/cp/rx/Subject.lua line 39