I have a server function decorated with @anvil.server.callable
which I also wish to call from another, non-decorated server function.
I appear to have to still use @anvil.server.call()
when calling such a decorated function.
My question is - does Anvil recognise this is not a front to back end communication and just call the function normally, or does it in fact introduce an overhead to the call?
Up until now, I have used what I think of as a “light controller” methodology of providing the decorated function that calls a non-decorated function. This allows both front end and back end to share it.
I have a feeling that I might be overthinking it a bit, though.
Why can’t you just call the decorated function in the normal fashion? anvil.server.call
is expensive when you’re already on the server side.
If there is some good reason, you could move the code into a undecorated function. Your decorated function then becomes just a one liner to call it and you can also call it from anywhere else.
I thought it might be expensive, but the function is not recognised if I call it directly.
Ok…ignore me. The question is unmitigated twoddle.
Something must have happened in the past for me to think this happened, but you can clearly call a server decorated function from another function, decorated or not.
Sorry for the noise…
1 Like
This seems strange. Why is the function not recognised I wonder. In what way?
Did the import statement cause an issue?
In case you were wondering, the reason that anvil.server.call()
always goes via the Anvil API router (aka the “dispatcher” if you’re fond of reading the source) is because that function might have been registered by the uplink, which takes priority over Server Modules!