Event Handlers in Custom Component

In normal components, we can do actions after some events:

It would be great if such events can be emitted from a custom component

Hey sigkill, Currently you can trigger queries from within custom components with the triggerQuery function, so you can trigger queries in your Retool app within your custom component after events. If you need other event handler functionality, you could create a dummy query that always succeeds and does nothing with an event handler(s) set to run 'On success'.

You could then trigger this query from within your app when needed. I hope that helps you with your use case for now!

Thank you for your help.
I am sorry I messed up with the names

The title originally writes "Custom Component"
I would like to ask about "Event Handlers" in a "Module".

For now, a module cannot emit some events to the app that uses it.

Hey sigkill, You should be able to "emit events" to the parent app from within a module using a dummy query workaround.

Create a Temporary State value and a module output with that temp state as the value (both on the left side panel). You'll then update the Temp State value from within your module whenever you want to trigger your event in the outside app. The value itself doesn't matter, all we need is a value that we can change. I toggle the value between true and false in my example.

In your parent app create a 'Query JSON with SQL' dummy query where you select * where {{module.output}}. This query will need to be set to 'Run query automatically when inputs change' to watch for changes to output1 and trigger this query when the output changes. You can then set event handlers on this dummy query to run on 'Success'.

Voila! You can now "emit events" from your module to your parent app :slightly_smiling_face: I hope this works for your use case!

1 Like

Thank you for your help! Greatly Appreciated! :stuck_out_tongue:

is a more DRY method of achieving this in the works?