#cp.rx.BehaviorSubject

A Subject that tracks its current value. Provides an accessor to retrieve the most recent pushed value, and all subscribers immediately receive the latest value.


#API Overview

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


#API Documentation

#Methods

Signaturecp.rx.BehaviorSubject.create(...) -> cp.rx.BehaviorSubject
TypeMethod
DescriptionCreates a new BehaviorSubject.
Parameters
  • ... - The initial values.
Returns
  • The new BehaviorSubject.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/rx/BehaviorSubject.lua line 15

Signaturecp.rx.BehaviorSubject:getValue() -> anything
TypeMethod
DescriptionReturns the last value emitted by the BehaviorSubject, or the initial value passed to the constructor if nothing has been emitted yet.
Parameters
  • None
Returns
  • The last value.
Notes
  • You can also call the BehaviorSubject as a function to retrieve the value. E.g. mySubject().
ExamplesNone
Sourcesrc/extensions/cp/rx/BehaviorSubject.lua line 80

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

Signaturecp.rx.BehaviorSubject:subscribe(observer, onError, onCompleted) -> cp.rx.Reference
TypeMethod
DescriptionCreates a new Observer and attaches it to the BehaviorSubject. Immediately broadcasts the most recent value to the Observer.
Parameters
  • observer - The Observer subscribing, or the function called when the BehaviorSubject produces a value.
  • onError - A function called when the BehaviorSubject terminates due to an error.
  • onCompleted - A function called when the BehaviorSubject completes normally.
Returns
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/rx/BehaviorSubject.lua line 37