View Source Chord.Delta.Formatter.Behaviour behaviour (Chord v0.1.0)

Defines the behaviour for delta formatters.

This behaviour allows developers to implement custom delta formatting logic tailored to their application's requirements. By adhering to this behaviour, developers can ensure that their formatter modules integrate seamlessly with Chord's delta management system.

Example Implementation

defmodule MyCustomFormatter do
  @behaviour Chord.Delta.Formatter.Behaviour

  @impl true
  def format(delta, context_id) do
    Enum.map(delta, fn {key, change} ->
      %{
        key: key,
        context: context_id,
        action: change.action,
        details: change
      }
    end)
  end
end

Summary

Callbacks

format(delta, context_id)

@callback format(delta :: map(), context_id :: any()) :: [map()]