[Modules] Can an app be informed that a module has completed a request?

I have a module that triggers requests.

In the app where I am using this module, I'd like to refresh part of the app once the module has completed those requests.

Is there a way to listen to a module's request completion?

1 Like

Hello!

Is there anyone who has a workaround for this?

It's too bad as it defeats the purpose of modules...

You could potentially use a module output, and expose the query's isFetching property like so:

Would this work for your use case?

Hello Mark,

Thanks for your answer!

I wasn't aware of the isFetching property. I tried it and it works indeed, I can see the value going from false to true and then false again from the app.

But how I can react to this state change to reload a table in the app?

One potential way I can think to do this is by using a "Query JSON with SQL" query which is set to "Run query automatically when inputs change" with the query being something like

select * from {{module.outputName}}Then set the query which populates the table to run on success of this query. In the end it would look something like this:

This will cause the query which populates the table to be re-run any time that the module output changes state.

2 Likes

Thanks Mark!

Indeed, it did the trick!

The only drawback of that workaround is that the Query2 is run twice (once when the request from the module starts and once when the request from the module completes). But it works :+1:

Awesome! Glad this workaround is working for you!

If running Query2 twice is an issue for you, you could create a JS query to go between the Query JSON with SQL query and the table query. This JS query would just have some simple logic to check if the isFetching value is true or false, and only trigger the table query when isFetching is false.