`after_transaction` and `before_transaction` hooks
zachdaniel:
I’ve just pushed two new changeset hooks (they have not been added for query, and probably won’t be any time soon).
changeset
|> Ash.Changeset.before_transaction(fn changeset ->
# this is a good place to do some network calls
# or set up your action in a way that doesn't do database work, but should only happen once
end)
|> Ash.Changeset.after_transaction(fn
changeset, {:ok, result} ->
# This is a good place to potentially do some cleanup, or things that could fail but shouldn't abort a transaction
# Additionally, you can modify the result here
changeset, {:error, error} ->
# You can do some handling of errors here, or also potentially *intercept* the error
# i.e you can return `{:ok, result}`
end)