> ## Documentation Index
> Fetch the complete documentation index at: https://doc.lucidworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# lifecycle:on

[localhost link]: http://localhost:3000/docs/4/app-studio/reference/tags/lightning.directive.lifecycleOn

[mintlify link]: https://doc.lucidworks.com/docs/4/app-studio/reference/tags/lightning.directive.lifecycleOn.md

[old doc.lw link]: https://doc.lucidworks.com/app-studio/4.2/1152.md

> [card] Key questions to get you started
>
> Powered by Lucidworks Agent Studio

## Description

Shows or hides elements when an event is broadcast

## Usage

as element:

```xml wrap  theme={"dark"}
<lifecycle:on
       event="{string}"
       hide="{boolean}"
       show="{boolean}">
</lifecycle:on>
```

#### Parameters

| Param | Type | Details |
| - | - | - |
| event | **string** | The name of the event to be listened to |
| hide | **boolean** | If true when the event is heard the elements will be hidden. |
| show | **boolean** | If true when the event is heard the elements will be shown. |

## Example

#### Source

```xml wrap  theme={"dark"}
<p>An event called foo will broadcast in 5 seconds.</p>
<lifecycle:delay delay="5000">
    <lifecycle:event event="foo">
        <search:alert style="alertbox-positive">Event foo has been broadcast</search:alert>
    </lifecycle:event>
</lifecycle:delay>
<lifecycle:on event="foo">
    <lifecycle:delay delay="1000">
        <search:alert style="alertbox-positive">Event foo has been heard so I have appeared!</search:alert>
    </lifecycle:delay>
</lifecycle:on>
<lifecycle:on event="foo" hide="true">
    <search:alert style="alertbox-warning">When I hear the event foo I will hide!</search:alert>
</lifecycle:on>
```

#### Result

![Result](https://mintcdn.com/lucidworks/ENcE8K39c0iEpL8J/assets/images/app-studio/as-examples/tags/lifecycleOn.png?fit=max\&auto=format\&n=ENcE8K39c0iEpL8J\&q=85\&s=d372a2b2d45876481aa660475bc9a28c)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.