# `event.emit_invalid`

Emit is given something that isn't an event, or is used outside an action.

Area 12, [Jobs and events](../topics/jobs-and-events.md); not declinable; the next step is usually the agent's.

Only an action emits, and only an event; a function emits by calling an action:

```jadpo
type Note = Text {
    max_length: 200
}

type NoteSeen = Event {
    note: Note
}

function seen(note: Note) -> NoteSeen {
    emit NoteSeen {
        note: note
    }
    return NoteSeen {
        note: note
    }
}
```

```text
error: A function can't emit `NoteSeen`
 --> main.jadpo:10:5
   |
10 |     emit NoteSeen {
   |     ^^^^^^^^^^^^^^^ only actions emit
  reason: An event is kept in the same transaction as an action's writes and handed to its subscribers once it commits, so only actions emit; a function emits by calling an action.
  next: Move the `emit` into the action this code calls, or make this an action (agent)
  rule: event.emit_invalid
  help: https://jadpo.dev/docs/errors/event.emit_invalid

check failed: 1 error, 1 file
```
