# Block component until event completion

**URL:** <https://forum.inductiveautomation.com/t/block-component-until-event-completion/104503>\
**Category:** Module Development\
**Tags:** perspective\
**Created:** [April 1, 2025, 11:33am UTC](https://forum.inductiveautomation.com/t/block-component-until-event-completion/104503 "2025-04-01T11:33:41Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![mykhaylo.hryhoryev](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@mykhaylo.hryhoryev](https://forum.inductiveautomation.com/u/mykhaylo.hryhoryev)\
**Post date:** [April 1, 2025, 11:33am UTC](https://forum.inductiveautomation.com/t/block-component-until-event-completion/104503/1 "2025-04-01T11:33:41Z")

</div>

Hello. I am trying to create a perspective component that fires a component event (eg. onActionPerformed) and waits for the full execution before allowing the user to fire another. The idea is for the user to not have the need to handle the state of the component. Is there a way to implement a functionality like this?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 1, 2025, 3:49pm UTC](https://forum.inductiveautomation.com/t/block-component-until-event-completion/104503/2 "2025-04-01T15:49:14Z")

</div>

Yes,  
but actually no,  
but actually yes.

The simplest solution would to be to render your component differently (e.g. `pointer-events: none`) or similarly, or otherwise _in the frontend_ stop firing events from your component. This is the first yes.

But, because browsers are running on the end user's machine, this can absolutely be circumvented or abused by sufficiently motivated people. Whether that matters to you is up to your environment - but if you're running in a typical desktop browser, be aware that any client side "security" is defeated as simply as by opening browser dev tools. This is the no.

The **correct** way to do this would be to lock out event processing on the gateway _and_ the client. The client is informed it shouldn't send events, and outside of rare/malicious scenarios, it won't - but the gateway doesn't bother to trust this and locks out event submission itself anyways. This is the second yes.

This absolutely **can** be implemented with your own backend `ComponentModel` implementation. There isn't a lot of prior art on the state transitioning necessary, but it wouldn't be that hard to add your own.

However, this may not be a good idea at all. What is your intention with this component/what are you really trying to do? Maybe there's a better paradigm for the whole interaction in general.

---

<div class="post-metadata">

**Author:** ![mykhaylo.hryhoryev](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@mykhaylo.hryhoryev](https://forum.inductiveautomation.com/u/mykhaylo.hryhoryev)\
**Post date:** [April 2, 2025, 3:28pm UTC](https://forum.inductiveautomation.com/t/block-component-until-event-completion/104503/3 "2025-04-02T15:28:58Z")

</div>

I am trying to create a component with a button that fires a custom component event onActionPerformed and sets the react component state as isExecuting = true. This variable isExecuting will prevent the components from firing more events but after the execution there is no easy way to set it to false.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 2, 2025, 3:42pm UTC](https://forum.inductiveautomation.com/t/block-component-until-event-completion/104503/4 "2025-04-02T15:42:13Z")

</div>

Sure there is; from the backend (the `ComponentModel` implementation) you can fire an outgoing event:

> <https://github.com/inductiveautomation/ignition-sdk-examples/blob/aafc6c3ce2c93841f2856c8e0124c7cec33167ea/perspective-component/gateway/src/main/java/org/fakester/gateway/delegate/MessageComponentModelDelegate.java#L101-L103>

Which you can then listen for in your frontend component:

> <https://github.com/inductiveautomation/ignition-sdk-examples/blob/aafc6c3ce2c93841f2856c8e0124c7cec33167ea/perspective-component/web/packages/client/typescript/components/Messenger.tsx#L136-L155>

And trigger whatever internal frontend component state update you need.

---

<div class="post-metadata">

**Author:** ![mykhaylo.hryhoryev](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@mykhaylo.hryhoryev](https://forum.inductiveautomation.com/u/mykhaylo.hryhoryev)\
**Post date:** [April 2, 2025, 5:09pm UTC](https://forum.inductiveautomation.com/t/block-component-until-event-completion/104503/5 "2025-04-02T17:09:53Z")

</div>

Can this method execute a user defined action:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/a/2a1ee87f67b43200c534de4d3a6b9353f366ec3b.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 2, 2025, 8:28pm UTC](https://forum.inductiveautomation.com/t/block-component-until-event-completion/104503/6 "2025-04-02T20:28:26Z")

</div>

Yes, from the frontend:

```python
    @bind
    actionPerformed() {
        this.props.componentEvents.fireComponentEvent("onActionPerformed", {});
    }

```

Or the backend, via [`Component.fireEvent`](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.47/com/inductiveautomation/perspective/gateway/api/Component.html#fireEvent(java.lang.String,java.lang.String,java.lang.Object)); the first parameter will be `com.inductiveautomation.perspective.common.config.EventConfig.COMPONENT_EVENTS` and the second parameter would be the name of the event.

---

<div class="post-metadata">

**Author:** ![mykhaylo.hryhoryev](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@mykhaylo.hryhoryev](https://forum.inductiveautomation.com/u/mykhaylo.hryhoryev)\
**Post date:** [April 4, 2025, 4:43pm UTC](https://forum.inductiveautomation.com/t/block-component-until-event-completion/104503/7 "2025-04-04T16:43:02Z")

</div>

I tried implementing following the Messenger example but couldn't make it work:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/c/bc1e941477fd63b94d784b0eff4c281ee8e71b28.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/3/93f67cb934bb95190a886f1115f2d51eef32bba0.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/8/3800d5f0e9d9bae7208a954316f5a614c7e1250c.png)

The log "Fired onActionPerformed" showed right after the "Received EventFiredMessage of type: start-action" and then it executed the action. How can I wait for the execution of the component to end so the log shows after the "Button 5 seconds" log?

---

<div class="post-metadata">

**Author:** ![bmusson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmusson/32/87530_2.png) [@bmusson](https://forum.inductiveautomation.com/u/bmusson)\
**Post date:** [April 4, 2025, 5:28pm UTC](https://forum.inductiveautomation.com/t/block-component-until-event-completion/104503/8 "2025-04-04T17:28:08Z")

</div>

I believe you'll need to run the code after `this.component.fireEvent` in the session queue `this.component.getSession().queue()::submit`.

---

<div class="post-metadata">

**Author:** ![mykhaylo.hryhoryev](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@mykhaylo.hryhoryev](https://forum.inductiveautomation.com/u/mykhaylo.hryhoryev)\
**Post date:** [April 7, 2025, 12:58pm UTC](https://forum.inductiveautomation.com/t/block-component-until-event-completion/104503/9 "2025-04-07T12:58:28Z")

</div>

Tried it but didn't work. The gateway code still manages to run before the user code.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/0/502778f73fb618fc17cc1cba920aeaa410353293.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/7/671ad28aff84289cc96e5fc6b9097ccaebe9ce65.png)

---

<div class="post-metadata">

**Author:** ![bmusson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmusson/32/87530_2.png) [@bmusson](https://forum.inductiveautomation.com/u/bmusson)\
**Post date:** [April 7, 2025, 4:17pm UTC](https://forum.inductiveautomation.com/t/block-component-until-event-completion/104503/10 "2025-04-07T16:17:47Z")

</div>

Going off memory here; I think the `handleEvent` is always queued?

So if you want in your function to run after the most recently queued event (i.e. your ‘fireEvent`), you’ll always want to submit to the back of the queue?

---

<div class="post-metadata">

**Author:** ![mykhaylo.hryhoryev](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@mykhaylo.hryhoryev](https://forum.inductiveautomation.com/u/mykhaylo.hryhoryev)\
**Post date:** [April 8, 2025, 10:37am UTC](https://forum.inductiveautomation.com/t/block-component-until-event-completion/104503/11 "2025-04-08T10:37:01Z")

</div>

Sorry but I didn't understand your last message.

Tried to analise the ignition default component behaviour but its hard without proper documentation. Is there something that can help me understand how the communication/event handling in ignition works? I feel it will help me find a solution to my problem.

---

<div class="post-metadata">

**Author:** ![bmusson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmusson/32/87530_2.png) [@bmusson](https://forum.inductiveautomation.com/u/bmusson)\
**Post date:** [April 8, 2025, 1:59pm UTC](https://forum.inductiveautomation.com/t/block-component-until-event-completion/104503/12 "2025-04-08T13:59:10Z")

</div>

Trying changing from:

```java
if(queue.isInQueue()) {
   func.run();
} else {
   queue.submit(func);
}

```

to simply:

```java
queue.submit(func);

```

> [@mykhaylo.hryhoryev](#):
>
> Is there something that can help me understand how the communication/event handling in ignition works? I feel it will help me find a solution to my problem.

It'd be nice, but I don't know of any resources. FAFO + lots of logging 🤷‍♂️.

---

<div class="post-metadata">

**Author:** ![Benjamin\_Furlani](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/benjamin_furlani/32/66084_2.png) [@Benjamin\_Furlani](https://forum.inductiveautomation.com/u/Benjamin_Furlani)\
**Post date:** [April 8, 2025, 2:06pm UTC](https://forum.inductiveautomation.com/t/block-component-until-event-completion/104503/13 "2025-04-08T14:06:00Z")

</div>

> [@bmusson](#):
>
> FAFO + lots of logging

This is what I needed on this cold Tuesday.

---

<div class="post-metadata">

**Author:** ![mykhaylo.hryhoryev](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@mykhaylo.hryhoryev](https://forum.inductiveautomation.com/u/mykhaylo.hryhoryev)\
**Post date:** [April 8, 2025, 4:57pm UTC](https://forum.inductiveautomation.com/t/block-component-until-event-completion/104503/14 "2025-04-08T16:57:45Z")

</div>

> [@bmusson](#):
>
> to simply:
> 
> ```python
> queue.submit(func);
> 
> ```

Tried it but didn't work. Same behaviour:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/1/810a85cfb16a613a0155c38d4cb321a8eab60f6d.png)
