View Source OnePiece.Commanded.TypeProvider (OnePiece.Commanded v0.11.0)

Implements Commanded.EventStore.TypeProvider behavior. Using macros to generate the behavior.

Link to this section Summary

Functions

Imports all the types from another module defined by OnePiece.Commanded.TypeProvider.TypeProvider.

Registers a mapping from an name string to an Elixir Module that defines a struct.

Link to this section Functions

Link to this macro

import_type_provider(provider_mod)

View Source (macro)
@spec import_type_provider(provider_mod :: module()) :: Macro.t()

Imports all the types from another module defined by OnePiece.Commanded.TypeProvider.TypeProvider.

example

Example

defmodule UserTypeProvider do
  use OnePiece.Commanded.TypeProvider
  # ...
end

defmodule MyAppTypeProvider do
  use OnePiece.Commanded.TypeProvider

  import_type_provider UserTypeProvider
end
Link to this macro

register_type(name, struct_mod)

View Source (macro)
@spec register_type(name :: String.t(), struct_mod :: module()) :: Macro.t()

Registers a mapping from an name string to an Elixir Module that defines a struct.

example

Example

defmodule MyTypeProvider do
  use OnePiece.Commanded.TypeProvider,
    prefix: "accounts." # optional, adds the prefix to the type name

  register_type "account_created", AccountCreated
end