[Event System] Enable and disable EventHandler

[Event System] Enable and disable EventHandler

  
Forge Component
(19)
Published on 1 Nov by Leonardo Fernandes
19 votes
Published on 1 Nov by Leonardo Fernandes

Is it possible to enable and disable the EventHandler?

I would like to be able to enable and initially disable the EventHandler on a webblock. This because we have a lot of EventHandlers on the screen (70). But it is not necessary to invoke all of them, just the ones that have changed data in the webblock. It seems to  work to put an if around the EventHandler. But then you need to have a ajax refresh on your screen to switch the if and that is not very fast!

Is there another way to solve this?

Niek Oosterbeek wrote:

Is it possible to enable and disable the EventHandler?

I would like to be able to enable and initially disable the EventHandler on a webblock. This because we have a lot of EventHandlers on the screen (70). But it is not necessary to invoke all of them, just the ones that have changed data in the webblock. It seems to  work to put an if around the EventHandler. But then you need to have a ajax refresh on your screen to switch the if and that is not very fast!

Is there another way to solve this?

Hello Niek. It's not possible to disable an event handler (the only possibility is including it inside an if, like you've already mentioned).

But there are a few things you may try. You can implement the OnNotify callback, and simply do-nothing if your data wasn't changed, by placing an if right at the start of the OnNotify action.

Other thing that you might try is to iterate over all event handlers. There is the GetEventHandlers action on the events module, which return a record list of event handlers inside a container, without invoking them. Then, you can decide if you want to invoke it or not.