Update custom component model from JS Query

I have a custom component that I have built that tracks the status of a download. The download is triggered from within the custom component and calls a REST API query in the main Retool page. Everything works fine except that I want to track the action of downloading so I can let the user know that they need to wait (and subsequently, that the task has completed).

To do so I have created an initial property in the component model named 'downloading' with the default set to 'false'. When I click on a document to download I set the 'downloading' variable to true and then call my REST API.

When the REST API is finished I set 'downloading' to false (and I can see that in Retool) -- however that isn't relayed to the custom component.

I thought I saw this covered somewhere but I cannot find it and the documentation here: Develop custom components doesn't cover how to update the component model -- just how to initialize it.

Hey @Ron_West! Have you seen this section of that doc? :slight_smile:

https://docs.retool.com/docs/custom-components#pass-data-from-your-app-to-your-custom-component

Basically, if you pass this variable into the model, you can reference the variable value inside your custom component!

Hi @victoria thanks for your reply. I am looking to make sure that changes to that variable ALSO make it into the component, not just the initial value.

That should work once you add your variable to the model object. Is that not what you’re seeing currently? Would you mind sharing your current component’s config? I’d also be happy to step into your app if that would be helpful!

Oh snap! That worked. Thank you!!!

Awesome!!! So glad to hear it :slight_smile: :raised_hands: