Skip to content

Instantly share code, notes, and snippets.

@anagromataf
Created December 20, 2018 14:29
Show Gist options
  • Save anagromataf/9ede3ff8470145bba566e51a0e827d20 to your computer and use it in GitHub Desktop.
Save anagromataf/9ede3ff8470145bba566e51a0e827d20 to your computer and use it in GitHub Desktop.
def apply(action, state, args, store, ref, revision) do
with {:ok, transaction} <- action.prepare(state, args),
{:ok, transaction_ref} <- store.prepare(ref, revision, action, transaction),
{:ok, new_state, result} <- action.commit(state, transaction),
{:ok, revision} <- store.commit(ref, transaction_ref, new_state) do
{:ok, new_state, revision, result}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment