Cqrs.BoundedContext.Commanded (cqrs_tools v0.3.13) View Source

If you are a Commanded user, you have already registered your commands with your commanded routers. Instead of repeating yourself, you can cut down on boilerplate with the import_commands/1 macro.

defmodule Users do
  use Cqrs.BoundedContext
  use Cqrs.BoundedContext.Commanded

  import_commands CommandedRouter

  query GetUser
end

Link to this section Summary

Functions

Imports all of a Command Router's registered commands.

Link to this section Functions

Link to this macro

import_commands(router, opts \\ [])

View Source (macro)

Imports all of a Command Router's registered commands.

Options

  • :only - Restrict importing to only the commands listed
  • :except - Imports commands except those listed
  • :after - a list of function names and a function of one arity to run with the execution result

Example

import_commands Example.Users.Router,
  except: [CreateUser],
  after: [
    reinstate_user: &AfterExecution.load_user/1,
    suspend_user: &AfterExecution.load_user/1
  ]