# Reacting in another domain

One domain changes another in one of two ways
([Ownership and calls replace modules](ownership-and-calls-replace-modules.md)):
it calls one of the other domain's `public` actions, or it emits an event
the other domain subscribes to.

| | Public action | Event |
|---|---|---|
| When | Inside the caller's transaction | After the caller commits |
| If it fails | The caller fails and everything rolls back | Only the subscriber's delivery fails; the emitter is unaffected |
| Who knows whom | The caller names the action | The emitter does not know who listens |
| Use for | Rules that must hold together (reserve stock with the order) | Reactions that may happen later (send the confirmation email) |

The subscriber lives in the domain that reacts, and calls that domain's
own action. The event must be `public` in the domain that emits it. Here
the `notifications` domain emails someone when a todo in `planning` is
completed:

```jadpo
// domains/notifications/subscribers/email_on_completion.jadpo
subscriber email_on_completion {
    on: TodoCompleted
    run: send_completion_email(event)
}

// domains/notifications/actions/send_completion_email.jadpo
action send_completion_email(event: TodoCompleted) fails EmailRejected -> Unit {
    ...
}
```
