I’m using the behaviour pattern to define how something should be implemented.
The function I am defining accepts a module as a parameter, which allows me to inject different modules (for testing, easily switching up implementations used, etc).
I couldn’t find something appropriate in the Kernel.Typespec docs so what I have done at the moment is something like this;
@callback my_func(some_var :: String.t, this_is_my_dependency :: Module) :: success | error
This is how the implementation is defined;
def my_func(some_var, this_is_my_dependency \\ MyDependency), do: ...
I’d appreciate some guidance on the best way to write this. Thanks for reading