Can you extract actions into their own module?

I’m back to working on my side project and I had a quick question about actions inside of a resource. As time goes on, I find the resource file potentially growing larger and larger as more and more actions are added. Is there a way to extract the actions into a separate module to help keep the resource file itself fairly lean? For example, maybe something like this:

alias MyApp.CoolDomain.CoolItem.Actions

# ... lots of other code

actions do
  create Actions.CreateMyCoolItem
  update Actions.UpdateMyCoolItem

  # ... etc, etc, etc
end

I’ve tried searching for documentation or examples of this, but I haven’t found any. If this is similar to my other questions, I’m sure there’s a page explaining how to do this exactly but I somehow missed it. Also, if it is possible, what do the modules look like? Am I still able to use the normal action structure inside a file other than a resource?

1 Like

:wave: there is a way to do this without throwing out the DSL goodness :smiley: Its a feature of Spark so maybe a bit harder to find. We should add a page for handling large resources in the Ash docs.

https://hexdocs.pm/spark/split-up-large-dsls.html

3 Likes

Perfect! That’s exactly what I was looking for. And, just like I thought, it was a feature that already existed. :joy: Thanks for the help yet again!