How to check if module query input is bound before triggering

My module has an input of type query, onOkay.

It’s fired when the Okay btn is pressed in my module’s modal.

The parent app doesn’t always need to make use of this event handler. However, if I do not bind to that query input when using the module, I will always get an error:

In the module, can we conditionally check if the query input has been bound to before attempting to trigger, or catch specific “this isn’t bound” errors? Like so:

Hey thanks for waiting @hansontools! This has actually come up before, see thread below

The recommended pattern from that thread is a null-check guard before triggering, which is essentially your option:

if (onOkay.query) {  onOkay.trigger()}

Or as a one-liner using short-circuit evaluation like above:

onOkay.query && onOkay.trigger()

When the parent app binds a query to onOkay, .query is truthy and .trigger() runs. When nothing is bound, .query is falsy and the trigger is skipped, no error banner.

Hope that helps! Let me know :folded_hands: