#cp.rx.go.If

A Statement that will check if a resolvable matches a predicate, then executes other resolvables.


#Submodules


#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.go.If(value) -> If
TypeConstructor
DescriptionCreates a new If Statement which will check the first result of value.
Parameters
  • value - a resolvable value that will be checked.
Returns
  • The Statement instance which will check if the resolvable matches the requirement.
Notes
  • By default, it will check if the value is truthy - not nil and not false.
  • Other checks can be specified via the If:Is/IsNot/Matches methods.
  • If the check passes, the If:Then(...) method is processed. If not, the Otherwise method
  • can specify other resolvables to execute instead.
  • Example:
  • lua</li><li>If(someObservable):Is(true):Then(</li><li> function() ... end</li><li>):Otherwise(</li><li> function() ... end</li><li>)</li><li>
ExamplesNone
Sourcesrc/extensions/cp/rx/go/If.lua line 46

#Methods

Signaturecp.rx.go.If:Are(value) -> If.Are
TypeMethod
DescriptionSpecifies the value to check.
Parameters
  • value - The value to wait for.
Returns
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/rx/go/If.lua line 233

Signaturecp.rx.go.If:AreNot(value) -> If.AreNot
TypeMethod
DescriptionSpecifies the value to check.
Parameters
  • value - The value to not match.
Returns
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/rx/go/If.lua line 288

Signaturecp.rx.go.If:Is(value) -> If.Is
TypeMethod
DescriptionSpecifies the value to check.
Parameters
  • value - The value to check for.
Returns
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/rx/go/If.lua line 218

Signaturecp.rx.go.If:IsNot(value) -> If.IsNot
TypeMethod
DescriptionSpecifies the value to not match.
Parameters
  • value - The value to check for.
Returns
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/rx/go/If.lua line 274

Signaturecp.rx.go.If:Matches(predicate) -> If.Matches
TypeMethod
DescriptionSpecifies the predicate function that will check the value results.
Parameters
  • predicate - The function that will get called to determine if it has been found.
Returns
Notes
  • Example:
  • lua</li><li>If(someObservable):Matches(function(value) return value % 2 == 0 end):Then(doSomething())</li><li>
ExamplesNone
Sourcesrc/extensions/cp/rx/go/If.lua line 329

Signaturecp.rx.go.If:Then(...) -> If.Then
TypeMethod
DescriptionCall this to define what will happen if value resolves successfully.
Parameters
  • ... - The list of resolveable values to process for the successful If result.
Returns
  • The Then Statement.Modifier.
Notes
  • The parameters can be any resolvable type.
  • For example:
  • lua</li><li>If(anObservable)</li><li>:Then(function(aResult)</li><li> doSomethingWith(aResult, anotherResult)</li><li> return true</li><li>end)</li><li>
ExamplesNone
Sourcesrc/extensions/cp/rx/go/If.lua line 123