What I’m looking for is API similar to mix
Protocol, but I don’t want to create
struct for every implementation, because that struct will be not modified (only default values), so it does not make sense.
I need to have
List of them dynamically, so my project could be used as a library and developer could add their own implementations.
I also want to declare optional and required API.
I’m looking for something like this:
defprotocol ProtocolName do # api here ... end defimpl ProtocolName, for: :identifier do # api implementation here end first_result = :identifier |> Protocol.find_implementation |> apply(:api_method, ) second_result = ProtocolName |> Protocol.implementations_for |> Enum.map(&apply(&1, :api_method, )) |> Enum.flatten
Is it possible to write in Elixir?