New: Sync Functions

Hi @Erin_Masatsugu Can you please add this to our organization kodeclubs

Hi @Erin_Masatsugu! Thanks for the helpful distinction between JS queries, transformers, and sync functions.

Would you mind sharing your thoughts on where variables fit into this as well? Anything interesting about how they could work with sync functions?

I know variables are a bit different, and you all are working on simplifying/merging the concepts, but I'd love to know if they'll stick around or get phased out.

Hello @Erin_Masatsugu Can you enable this for our organization kodeclubs

This is what I have feature request in 2023 :grinning:

1 Like

Hi Matei,

Great question -- I'll update this in the FAQ also.

Variables are helpful when you want to store some state and explicitly update its value from other parts of your app (ex. from an event handler). I can see sync functions being helpful if you wanted to encapsulate logic for calculating a value to store to a variable (whether that be to set the initial value or from some other part of the lifecycle of your app).

We believe that this concept is valuable in building apps, so we're planning on preserving that functionality.

Hope that helps!
Erin

1 Like

Thank you @Erin_Masatsugu!

Definitely, very helpful. Using sync functions to update variables makes sense & is common enough to be useful.

My last questions are off topic at this point, so no need to answer here, but I hope they are included in docs (and your original post) at some point!

  • Where does local storage fit in here, especially in the context of multi-page apps? (obv it’s the only one that can persist state between apps)
  • What is the relative performance of reading from (or writing to) variables vs. local storage vs. transformers?
  • Does it make more sense to use a transformer that returns part of local storage state or a sync function that does the same? (Only difference I can imagine is that sync functions can’t be used in-line on components)

Thanks!

Hi Matei,

  • Historically, yes local storage would be the best option for sharing data across apps, but with the multi-page feature, you should be able to use Retool primitives to share state between pages within an app.
  • Local storage vs variables -- I would imagine these are quite comparable, with maybe a slight overhead cost associated with local storage, just due to the extra layer of abstraction, but I can confirm with the team and get back to you.
  • Transformers vs sync functions -- this is case-by-case. The benefit to sync functions is you can call them inline and calculate the result on the fly, rather than having to create "global state" by way of a transformer. This is probably the best pattern if you only want to use the result in a few places. A transformer is probably a better pattern if you want to re-use the result (execute the code with the same parameters) often.

Best,
Erin

1 Like

Hi @Erin_Masatsugu ,
Would it be possible to add tubescience.retool.com to the alpha?
It would be very helpful for us

Hi @Erin_Masatsugu !

I would love to try this! My org is oasisctrportal.retool.com

Thank you :smiling_face:

Thanks @Erin_Masatsugu -- super helpful response and I have a much better idea of which to use for our current and future needs.

Much appreciated :pray:

1 Like

I don't have an immediate need, but this looks super useful. Can I sign up anyway? dashtodash.retool.com

Please add: getcaravel.retool.com
Would love to give it a try, having a few concrete use cases in mind.

hi,

please add to snuipp.retool.com

thanks
Julien

That's exactly what we need. Got a complex table cell highlighting logic in 10s of places, that i could not put inside a transformer since it used currentRow. Sync functions seem like a solution.
Please allow to the following organizations:
https://vergo.retool.com
https://abdulwasae.retool.com

Could you please enable it for jitsecurity.retool.com ?
Thanks!

Interested - stackboost.retool.com please :slight_smile: