Module feature - have a way to trigger query on module input change

we have a setup like this,

parent-jsquery( say query A) -> module instance input query ( say ~ query B) -> module instance

right now A query call B query and pass in parameters to B. But the problem is, we want an ability to trigger query inside module instance when the query B changes, thats sort of the useEffect thing in react and IMO quite critical to bring more intelligence to retool module function.

contacted support and seems there are currently no way to do it( Great support btw, thanks much John and others in the support team! You guys rock)

The use case will be lots, say i have a table defined in module, instead of passing in the whole table data, i can just pass in the query parameter to the module and the module will just populate the table data.

5 Likes

I was able to use "useEffect" by referencing like so: React.useEffect...

Sort of like this:

const MyCustomComponent = ({ triggerQuery, model, modelUpdate }) => {

// In my case, I can only get hard-coded values to work, I cannot
// seem to pass a starting value in using the model...
const [timerId, setTimerId] = React.useState(0)

function scheduledEvent() {
setTimerId( timerId + 1 )
}

// This works, but seems to bog down after a while - not sure what that's about
React.useEffect(() => {
setInterval( scheduledEvent, 1000 );
}

return (

  <div className="card">{timerId}</div>

);
}

///////////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER: I'm a total React noob, so take this with a grain of salt.

1 Like