# relay_supervisor

A supervisor where older children can pass data to younger children!

[![Package Version](https://img.shields.io/hexpm/v/relay_supervisor)](https://hex.pm/packages/relay_supervisor)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://relay-supervisor.hexdocs.pm/)

This is useful any time a child needs to make use of another. For example, if
you have a web server that uses a database connection.

```sh
gleam add relay_supervisor@1
```
```gleam
import relay_supervisor as relay

fn start(credentials: String, hostname: String) -> _ {
  relay.new(fn(children) {
    children
    |> relay.add(
      relay.child(database.template)
      |> relay.providing(fn(_state) { credentials })
      |> relay.returning(fn(_state, db) { db })
    )
    |> relay.add(
      relay.child(web_server.template)
      |> relay.providing(fn(db) { #(db, hostname) })
    )
  })
}
```

See [HexDocs](https://relay-supervisor.hexdocs.pm/) for an explanation of this
code and for further documentation.
