An Action in deco.cx is a function that mutates data.
/actions/
folder of your project. They can be invoked in
response to user interactions, form submissions, or any other defined triggers.
By encapsulating data mutation logic within Actions, developers can manage and
track changes made to the application’s state, providing users with dynamic and
interactive experiences.
Note: While Loaders focus on fetching data from external sources, Actions concentrate on mutating data within the application. By leveraging both Loaders and Actions in deco.cx, developers can create powerful applications that fetch and manipulate data seamlessly.One of the great benefits of Actions is their ability to work in conjunction with Loaders and other blocks. While Loaders focus on fetching data, Actions focus on mutating data. This means that multiple Actions can be invoked from the same interface, allowing users to modify data from different sources or perform a series of related operations. By leveraging both Loaders and Actions, developers can create flexible and powerful applications that seamlessly integrate data fetching and mutation. In addition to mutating data, Actions in deco.cx can also export a typescript props type, which allows them to be configured in the Admin just like Sections.
newsletter/subscribe.ts
Action: