# New module: rx-tx-async-channel

**URL:** <https://racket.discourse.group/t/new-module-rx-tx-async-channel/1078>\
**Category:** Show & Tell\
**Created:** [June 13, 2022, 10:23pm UTC](https://racket.discourse.group/t/new-module-rx-tx-async-channel/1078 "2022-06-13T22:23:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dstorrs](https://avatars.discourse-cdn.com/v4/letter/d/898d66/32.png) [@dstorrs](https://racket.discourse.group/u/dstorrs)\
**Post date:** [June 13, 2022, 10:23pm UTC](https://racket.discourse.group/t/new-module-rx-tx-async-channel/1078/1 "2022-06-13T22:23:07Z")

</div>

This was posted just now and it's still waiting for the docs to be built.

> **[rx-tx-async-channel](https://pkgs.racket-lang.org/package/rx-tx-async-channel)**
>
> Defines a struct containing two async-channels in order to make bi-directional communication simple. Relies on the struct-plus-plus module.

Quoting the README:

Racket library that defines a struct containing two async-channels in order to make bi-directional communication simple. Relies on the `struct-plus-plus` module.

The two fields of the struct are called `to-child` and `to-parent` with the intent that the struct is created in one thread (the parent) and given to another thread (the child), and the fields specify who is expected to receive the messages--the parent thread receives messages that are put on `to-parent` and vice versa.

```scheme
; create one using struct-plus-plus keyword constructor and specifying the fields
(rx-tx-async-channel++ #:to-child (make-async-channel) #:to-parent (make-async-channel))
(define ch (rx-tx-async-channel++)) ; Allow both fields to default. You can also specify only one.

; retrieve the async-channels from within the struct
(rx-tx-async-channel.to-parent ch) ; returns an async-channel?
(rx-tx-async-channel.to-child ch) ; returns an async-channel?

; return latest message from an async channel, discarding everything along the way.
; If no message available, returns #f
(async-channel-most-recent-message (rx-tx-async-channel.to-child ch)) 

```
