callback v0.1.0 Callback
Link to this section Summary
Types
A generic callback form with any amount of arguments
An explicit callback form expecting 1 argument of the provided type, and returning a result of the provided type
An explicit callback form expecting 2 arguments of the provided type, and returning a result of the provided type
A module-function-arity tuple with an explicit arity
A module-function-parameter tuple
Functions
Call the provided callback with the given inputs
Returns true if term is a callback; otherwise returns false
Link to this section Types
A generic callback form with any amount of arguments.
An explicit callback form expecting 1 argument of the provided type, and returning a result of the provided type.
An explicit callback form expecting 2 arguments of the provided type, and returning a result of the provided type.
A module-function-arity tuple with an explicit arity.
mfp() ::
{module(), atom(), list()}
| {module(), atom(), list(), nil | non_neg_integer() | [non_neg_integer()]}
A module-function-parameter tuple.
This either contains a list of parameters that will be passed to the function,
and any input parameters will be added following those parameters. Or an input
index or list of indexes will be provided (in which case those inputs will be
inserted into the parameter list at those positions). Or nil inputs, if no
inputs should be included, this however is only applicable to calls where the
input requirements :optional.
{ Foo, :bar, [:a, :b] }
# If the callback is not passing any inputs then this function will
# be called as:
Foo.bar(:a, :b)
# If the callback is passing in 1 input ("hello"), then this function
# will be called as:
Foo.bar(:a, :b, "hello")
# If the callback is passing in 2 inputs ("hello", "world"), then this
# function will be called as:
Foo.bar(:a, :b, "hello", "world")
{ Foo, :bar, [:a, :b], 0 }
# If the callback is not passing any inputs then this function will
# be called as:
Foo.bar(:a, :b)
# If the callback is passing in 1 input ("hello"), then this function
# will be called as:
Foo.bar("hello", :a, :b)
# If the callback is passing in 2 inputs ("hello", "world"), then this
# function will be called as:
Foo.bar("hello", "world", :a, :b)
{ Foo, :bar, [:a, :b], [0, 2] }
# If the callback is not passing any inputs then this function will
# be called as:
Foo.bar(:a, :b)
# If the callback is passing in 1 input ("hello"), then this function
# will be called as:
Foo.bar("hello", :a, :b)
# If the callback is passing in 2 inputs ("hello", "world"), then this
# function will be called as:
Foo.bar("hello", :a, "world", :b)
{ Foo, :bar, [:a, :b], nil }
# If the callback is not passing any inputs then this function will
# be called as:
Foo.bar(:a, :b)
# If the callback is passing in 1 input ("hello"), then this function
# will be called as:
Foo.bar(:a, :b)
# If the callback is passing in 2 inputs ("hello", "world"), then this
# function will be called as:
Foo.bar(:a, :b)
Link to this section Functions
Call the provided callback with the given inputs.
The inputs to the callback are required by default but can otherwise be
made optional by passing :optional as the input_requirement.
Returns true if term is a callback; otherwise returns false.
Allowed in guard tests.