Opt-in capture hook for the ExBoxPacker.PackerPreview dev visualiser.
Enable in dev config and add the collector to your supervision tree:
# config/dev.exs
config :ex_box_packer, ExBoxPacker, preview: [enabled: true]
# application.ex (dev only)
children = [ExBoxPacker.Preview.Collector | rest]Then, after packing, capture the result:
{:ok, result} = ExBoxPacker.Packer.pack(boxes, items)
ExBoxPacker.Preview.capture(result, label: "order #123")When disabled (default) or the collector isn't running, capture/2 is a cheap no-op.
Summary
Functions
Capture a packing for the preview (no-op unless enabled and the collector is running).
Whether preview capture is enabled (config :ex_box_packer, ExBoxPacker, preview: [enabled: true]; default false).
Functions
@spec capture( ExBoxPacker.Result.PackedBoxList.t(), keyword() ) :: :ok
Capture a packing for the preview (no-op unless enabled and the collector is running).
@spec enabled?() :: boolean()
Whether preview capture is enabled (config :ex_box_packer, ExBoxPacker, preview: [enabled: true]; default false).
@spec pack([ExBoxPacker.Box.t()], [ExBoxPacker.Item.t()], keyword()) :: {:ok, ExBoxPacker.Result.PackedBoxList.t()} | {:error, Exception.t()}
Convenience: Packer.pack/3 then capture/2. Returns the pack/3 result.