Raxol.Protocols.BehaviourAdapter (Raxol v2.0.1)
View SourceAdapter module to help migrate from behaviours to protocols.
This module provides adapter functions that bridge the gap between the old behaviour-based system and the new protocol-based system, allowing for gradual migration without breaking existing code.
Usage
For modules implementing behaviours, you can use this adapter to automatically implement the corresponding protocols:
defmodule MyRenderer do
@behaviour Raxol.Terminal.RendererBehaviour
use Raxol.Protocols.BehaviourAdapter, :renderer
# Your existing behaviour callbacks...
endThis will automatically implement the Renderable protocol for your module.
Summary
Functions
Macro to inject protocol implementations based on behaviour type.
Wraps a behaviour-implementing module to work with protocol-expecting code.
Functions
Macro to inject protocol implementations based on behaviour type.
Wraps a behaviour-implementing module to work with protocol-expecting code.
Examples
# Old behaviour-based renderer
renderer = MyRenderer.new(buffer)
# Wrap it to work with protocol-expecting code
wrapped = BehaviourAdapter.wrap_renderer(renderer)
Raxol.Protocols.Renderable.render(wrapped, [])