Skip to content

Special function vs Event Handlers

Special Functions vs Event Handlers

Special Function and Event Handlers are two very useful features in Aliveforms. They might provide same functionality but they have different use cases.

Differences in Special Functions and Event Handlers.

  • In Aliveforms, on different occasion, system checks if a special function is defined. If it is defined, it executes the special function.

  • On the other side, on several occasions, Aliveforms dispatches the event. And Event Handlers registered with $.Handle handle that event.

  • There can be only 1 special function for 1 screen. e.g. window.screen_0_on_enter, but there can be multiple event handlers. So that is benefit of event handlers.

  • Special functions can return false in order to intercept execution e.g. window.screen_0_on_next_pre can return 0 if input length is less than 3 and show a custom error message. Same is not possible with event handlers. So that is benefit of special functions. It can be used for validations, debugging etc.

When to use Special Functions

If you are sure you work will be done inside one block of code, in special function, use special function. Or you want to intercept the execution based upon condition.

When to use event handlers?

If you are use multiple logic modules, each needs to handle for example screen_0_on_enter, use event handlers.