> For the complete documentation index, see [llms.txt](https://jsf.gitbook.io/jsf/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jsf.gitbook.io/jsf/other/events.md).

# Events

JSF form events can be split into two categories:

* external - things that are emitted into JSF from outside world (app)
* internal - things that are emitted from JSF to outside world (app)

You can listen on external events with `schema.$events.listen` keyword.&#x20;

For JSF to listen to itself there is in `JsfBuilder` subject called `onAnyEvent`. This subject emits all external and internal events, like onClick emit. You can also emit custom events for you own usage.

Example usage in layout:

```typescript
rootBuilder.onAnyEvent.subscribe(x => {
  if (x.type === 'internal') {
    const data = x.internalEvent; // type of JsfFormEventInterface
  }
})
```

You can also manually trigger any event call:

```typescript
rootBuilder.onAnyEvent.next({ type: 'custom', customEvent: 123 });
```

Subject interface:

```typescript
{
    type: 'internal' | 'external' | any,
    customEvent?: any;
    externalEvent?: { key: string, data: any },
    internalEvent?: JsfFormEventInterface
}
```
