# cp.rx.go

Defines [Statements](cp.rx.go.Statement.md) to make processing of
[cp.rx.Observable](cp.rx.Observable.md) values
in ways that are more familiar to synchronous programmers.

A common activity is to perform some tasks, wait for the results and
do some more work with those results.

Lets say you want to calculate the price of an item that is in US Dollars (USD) and
output it in Australian Dollars (AUD). We have `anItem` that will return an
[Observable](cp.rx.go.Observable.md) that fetches the item price, and an
`exchangeRate` function that will fetch the current exchange rate for two currencies.

Using reactive operators, you could use the `zip` function to achieve this:

```lua
Observable.zip(
    anItem:priceInUSD(),
    exchangeRate("USD", "AUD")
)
:subscribe(function(price, rate)
    print "AUD Price: ", price * rate
end)
```

The final subscription will only be executed once both the `priceInUSD()` and `exchangeRate(...)` push
a value. It will continue calling it while both keep producing values, but will complete if any of them
complete.

Using the [Given](cp.rx.go.Given.md) statement it would look like this:

```lua
Given(
   anItem:priceInUSD(),
   exchangeRate("USD", "AUD"),
)
:Now(function(price, rate)
    print "AUD Price: ", price * rate
end)
```

For more information on using and creating statements, see the
[Statements](cp.rx.go.Statements.md) documentation.

---

## Submodules
 * [cp.rx.go.Do](cp.rx.go.Do.md)
 * [cp.rx.go.Done](cp.rx.go.Done.md)
 * [cp.rx.go.First](cp.rx.go.First.md)
 * [cp.rx.go.Given](cp.rx.go.Given.md)
 * [cp.rx.go.If](cp.rx.go.If.md)
 * [cp.rx.go.Last](cp.rx.go.Last.md)
 * [cp.rx.go.List](cp.rx.go.List.md)
 * [cp.rx.go.Require](cp.rx.go.Require.md)
 * [cp.rx.go.Retry](cp.rx.go.Retry.md)
 * [cp.rx.go.SetProp](cp.rx.go.SetProp.md)
 * [cp.rx.go.Statement](cp.rx.go.Statement.md)
 * [cp.rx.go.Throw](cp.rx.go.Throw.md)
 * [cp.rx.go.WaitUntil](cp.rx.go.WaitUntil.md)

---

## API Overview

---

## API Documentation

---

<script src="https://giscus.app/client.js"
        data-repo="CommandPost/CommandPost"
        data-repo-id="MDEwOlJlcG9zaXRvcnk3NDY0NTk2NQ=="
        data-category="Website Discussion"
        data-category-id="DIC_kwDOBHMBzc4CXFFA"
        data-mapping="pathname"
        data-strict="0"
        data-reactions-enabled="1"
        data-emit-metadata="0"
        data-input-position="bottom"
        data-theme="dark"
        data-lang="en"
        crossorigin="anonymous"
        async>
</script>
