#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

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


#API Documentation

#Constructors

Signaturecp.rx.Subject.create() -> cp.rx.Subject
TypeConstructor
DescriptionCreates a new Subject.
Parameters
  • None
Returns
  • The Subject.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/rx/Subject.lua line 21

#Methods

Signaturecp.rx.Subject:onCompleted() -> nil
TypeMethod
DescriptionSignal to all Observers that the Subject will not produce any more values.
Parameters
  • None
Returns
  • None
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/rx/Subject.lua line 127

Signaturecp.rx.Subject:onError(message) -> nil
TypeMethod
DescriptionSignal to all Observers that an error has occurred.
Parameters
  • message - A string describing what went wrong.
Returns
  • None
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/rx/Subject.lua line 105

Signaturecp.rx.Subject:onNext(...) -> nil
TypeMethod
DescriptionPushes zero or more values to the Subject. They will be broadcasted to all Observers.
Parameters
  • ... - The values to send.
Returns
  • None
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/rx/Subject.lua line 86

Signaturecp.rx.Subject:subscribe(observer[, onError[, onCompleted]]) -> cp.rx.Reference
TypeMethod
DescriptionCreates 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
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/rx/Subject.lua line 39