I have a general question I’ve been meaning to ask and I think ChatGPT doesn’t fully understand and therefore doesn’t provide a good explanation. I’d love to here the pros opinions:
What is a better practice for production purposes, having one callback with one output and a few inputs, and using ctx.triggered_id with if/else clause(s), or a few different shorter callbacks with a duplicated output?
Appreciate your help.
Hello @odedloe87,
It really depends on your use cases, if all the same data is required, then you can use ctx and one callback.
If you need conditional responses, you can always use set_props to not have to always return however many props you are updating.
If you don’t need all the data, then you can use separate callbacks.
Another thing, you should try to optimize by using clientside when possible.
1 Like
Hi @jinnyzor ,
Thanks for your response! I completely agree that I should gain more experience with clientside callbacks. Since they involve quite a bit of JavaScript—which I’m not yet very comfortable with—I’ve been relying on ChatGPT to help with some of the implementation. That said, debugging can be tricky, and I often find myself reverting to server-side approaches instead.
If you have any recommended resources for improving my clientside skills, I’d really appreciate it.
Thanks again for your help!
Python and JS are fairly similar in approaches, once you figure out the things that make them different (structure, etc) then you should be able to swap.
For simple functions, swapping to JS should be straightforward. If doing actual data processing, I normally do it on the server. 