after()
import { after } from "@fed1/jsos";
A JSFunction
that defines a qualified method for the after
slot of a
multimethod.
An after method is called right after any primary methods are executed. It does not influence the inputs or outputs of the multimethod, but it can be used like an event listener to plug-in additional functionality like logging.
Usage
after(multimethod, comparators, fn)
Parameters
# | Parameter | Required? | Type | Default |
---|---|---|---|---|
1 | multimethod | yes | TGeneric | |
2 | comparators | yes | JSArray | |
3 | fn | yes | JSFunction |
1. multimethod
The multimethod to which an after
method shall be added.
2. comparators
An array of comparators (types) to which this method applies.
3. fn
The method body supplied as a callback function.
Return value
The JSFunction
that was used as the method body. Usually, you can just discard
this value. It becomes useful when you want to remove the added method later on
at runtime for which you need to keep a reference of the function.
Version History
Feature | Since version |
---|---|
after() | 1.0 |