# Events

To listen to DOM events you simply need to prepend event name with `on` prefix:

```jsx
<button
  onClick={ handler }
>
  click me
</button>
```

`handler` would receive native [Event](https://developer.mozilla.org/en-US/docs/Web/API/Event).

{% hint style="info" %}
**NOTE:** [DOM event list](https://developer.mozilla.org/en-US/docs/Web/Events) on MDN
{% endhint %}

### Events and Subjects

The best way to use events in you Recks components — is to push them into a local RxJS Subject:

```jsx
function App() {
  // events stream
  const input$ = new Subject();

  // accumulating stream
  const times$ = input$.pipe(
    startWith(0),
    scan(acc => ++acc)
  );

  return (
      <button onClick={ () => input$.next() }>
        Clicks: { times$ }
      </button>
  );
}
```

[online sandbox](https://codesandbox.io/s/events-example-3lvqc?file=/src/App.jsx)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://recks.gitbook.io/recks/api/events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
