Easier communication from a custom component back to the Retool app

Right now it is a bit clunky to send data back from a custom component. You can use modelUpdate, but if you change the model from the Retool side, the entire model can get reset back to its original values, clearing the model of any changes that were made.

You can do a modelUpdate and then fire a js query from the custom component what then sets a temp var to make sure the data is persisted. That is a bit of a hack.

What I imagine as a perfect solutions is something like an Output in a Module. You set the Output value and it shows up as a property of the component.

That way you have a Model as an input and Outputs as the, well, output.

I would then also add events. The model (or another mechanism) would define queries that can be called as if they were events, see this post, Pass events back from Module - #2 by bradlymathews, on doing something similar with Modules. I would allow passing back of parameters using this mechanism.

I know you can use triggerQuery to fire any query back in Retool, but having a more formal clarification of which queries a component could use would be safer.

5 Likes

Hi @bradlymathews

I'm totally with you about the mentioned features request.

To workaround the model reset issue I think you can do something more "elegant" by putting the custom comp into a Module, that way you can split the Model into different states, thus, Retool can reset only a portion of that Model.

Hope this help.

2 Likes

That is a a very interesting idea! Thanks.

1 Like