# Event Hooks

You can implement various event hooks from within your component file to respond to certain events that take place during the lifecycle of your integration.

### onDetailsOpened

This hook fires after the details block has opened and the DOM for the details block has finished loading.  This hook will fire multiple times if the user opens and closes the details block.

{% code title="components/component.js" %}

```javascript
polarity.export = PolarityComponent.extend({
   onDetailsOpened: function(){
      // executed after the user has expanded the details block and the
      // DOM is fully loaded. 
   }         
});
```

{% endcode %}

### onDetailsClosed

This hook fires after the details block is closed by the user.  This hook can fire multiple times if the user opens and closes the details hook.

{% code title="components/component.js" %}

```javascript
polarity.export = PolarityComponent.extend({
   onDetailsClosed: function(){
      // executed after the user has closed the details block
   }         
});
```

{% endcode %}

### onDetailsComplete

This hook fires when the details block has fully loaded its data including and data that might be fetched from the `onDetails` hook on the server.  Unlike the `onDetailsOpened` hook, the `onDetailsComplete` hook will only fire once after the details data is loaded. &#x20;

{% code title="components/component.js" %}

```javascript
polarity.export = PolarityComponent.extend({
   onDetailsComplete: function(){
      // executed after the details block has fully loaded its data including
      // data fetched by a server side `onDetails` implementation.
   }         
});
```

{% endcode %}

### onDetailsError

This hook fires if there was an error loading the details (i.e., the `onDetails` hook on the server returned an error). &#x20;

{% code title="components/component.js" %}

```javascript
polarity.export = PolarityComponent.extend({
   onDetailsError: function(error){
      // executed if the `onDetails` 
   }         
});
```

{% endcode %}


---

# 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://docs.polarity.io/integrations/build-an-integration/customizing-the-overlay-window/component-file/event-hooks.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.
