# 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

  • If

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

  • Are
  • AreNot
  • Is
  • IsNot
  • Matches
  • Then

# API Documentation

# Constructors

# If

Signature cp.rx.go.If(value) -> If
Type Constructor
Description Creates 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>
Examples None
Source src/extensions/cp/rx/go/If.lua line 46

# Methods

# Are

Signature cp.rx.go.If:Are(value) -> If.Are
Type Method
Description Specifies the value to check.
Parameters
  • value - The value to wait for.
Returns
Notes None
Examples None
Source src/extensions/cp/rx/go/If.lua line 233

# AreNot

Signature cp.rx.go.If:AreNot(value) -> If.AreNot
Type Method
Description Specifies the value to check.
Parameters
  • value - The value to not match.
Returns
Notes None
Examples None
Source src/extensions/cp/rx/go/If.lua line 288

# Is

Signature cp.rx.go.If:Is(value) -> If.Is
Type Method
Description Specifies the value to check.
Parameters
  • value - The value to check for.
Returns
Notes None
Examples None
Source src/extensions/cp/rx/go/If.lua line 218

# IsNot

Signature cp.rx.go.If:IsNot(value) -> If.IsNot
Type Method
Description Specifies the value to not match.
Parameters
  • value - The value to check for.
Returns
Notes None
Examples None
Source src/extensions/cp/rx/go/If.lua line 274

# Matches

Signature cp.rx.go.If:Matches(predicate) -> If.Matches
Type Method
Description Specifies 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>
Examples None
Source src/extensions/cp/rx/go/If.lua line 329

# Then

Signature cp.rx.go.If:Then(...) -> If.Then
Type Method
Description Call 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>
Examples None
Source src/extensions/cp/rx/go/If.lua line 123