Watched Inputs for JS queries

SQL queries and JSON SQL queries are reactive - they fire when used values changed.

I would love to have that for javascript queries as well. In fact it just hit me, this might replace the need for many types of events.

Rather than using my requested table.onLoad event, I could watch the table.data value and trigger a js query.

However, I still think the events are needed so we have a choice of which method to use.

Hey Brad!

Here's a quick workaround we use internally. We're planning on combining JS query and transformer functionality, but for now, this could work!

  1. Write a "Query JSON with SQL" query that just has whatever you want to watch, like {{tableName.recordUpdates}}, in the query field
  2. On Success, trigger your JS query that you want to trigger!
  3. This dummy Query JSON with SQL query type will run as soon as you hit enter after editing a cell, then it will trigger the target query!
1 Like

Yikes, no screenshot got attached. Here ya go!


@victoria,

Ok, I finally have a chance to try this and it is actually NOT working for select.value:

Hmm, after a bit of playing, it works if you put your query in On Failure instead of On Success!

Edit: The reason I need to do this is as a workaround to a bug in Select components where onChange does not fire with custom values: Select (Dropdown) component does not fire onChange with custom value - #2 by grace

Ah, yup! That query will fail, so the On Failure condition will run.

If you do select * from {{selNewShoppingItem.value}}, then it will succeed, so the On Success condition will run!

Sorry I didn't clarify this earlier + truly appreciate you clarifying on this thread for other viewers :)

2 Likes