Refactoring / Chaining server actions?

Hello dear Wappler community superstars !

I’m wondering how do you refactor your server actions when they get really big - and stuff gets repeated among several of them ?

Is there a way to “chain” server actions like you would call a “function” in a dev environment ?

Thank you very much for your help and have a great day !

Hello @jeoff75
Can you explain a little more detailed what is your case and what are you trying to achieve?

You can use the api action to call another server action and pass it parameters and then evaluate the output.

It would be much easier though if we had something that allowed reusable series of actions that could be inserted for a code once, use multiple times approach.

Thanks for asking.

I’m integrating our shopping cart with several payment gateways.

So the logic for single/recurring/trial payments is specific to each gateway.
But email notifications and database operations are common to each transactions.

Usually, I would have a “root” logic to dispatch to the correct gateway routine depending of which gateway has to process the payment.
Then the corresponding gateway routine would return a “standard” response that I can pass onto my database and notification routines.

Thank you for your help ! :slight_smile:

Thanks ! That might be the only option.
Just want to be sure what would be considered as the best practice right now.