```tsx
import {createAiChat, PreDestroyCallback, PreDestroyEventDetails} from '@nlux/core';

const preDestroyCallback: PreDestroyCallback = (preDestroyDetails: PreDestroyEventDetails) => {
    if (preDestroyDetails.conversationHistory.length > 0) {
        // Do something with the conversation history before it is destroyed
    }
};
```

```tsx
// Registering the preDestroyCallback when creating the AiChat instance
const aiChat = createAiChat().withAdapter(adapter).on('preDestroy', preDestroyCallback);
```

```tsx
// Registering the preDestroyCallback after creating the AiChat instance
// and before calling aiChat.unmount()
aiChat.on('preDestroy', preDestroyCallback);
```

```tsx
// Unregistering the preDestroyCallback
aiChat.removeEventListener('preDestroy', preDestroyCallback);
```
