   end
 
   defp dispatchp(reducers, type, data) do
+    #Logger.debug("Dispatch #{type}")
     Enum.reduce reducers, %{}, fn {reducer, options}, acc ->
       # Do the reducer and keep result.
       res = try do
         case Keyword.get(options, :type, :any) do
           :any ->
+            #Logger.debug("  Call reducer #{Keyword.get options, :name, :unknown}")
             reducer.(type, data)
           ^type ->
+            #Logger.debug("  Call reducer #{Keyword.get options, :name, :unknown}")
             reducer.(data)
           _ ->
             nil

        e in FunctionClauseError ->
          # Some voodoo to check it it was us with a wrong action type, if so ignore
          stacktrace = System.stacktrace
          case (hd (tl stacktrace)) do
            {EventSourcing, _, _, _} ->
              nil

  def subscribe(pid, :debug) do
    subscribe(pid, fn type, _data ->
      Logger.debug("Event #{type}")
    end, name: :debug)
  end
  def subscribe(pid, :debug_full) do
    subscribe(pid, fn type, data ->
      Logger.debug("Event #{type}(#{inspect data})")
    end, name: :debug_full)
  end
  def subscribe(pid, reducer), do: subscribe(pid, reducer, [])

