easy-api.ts lets you add custom functionality to the library,
that’s why creating custom functions is a thing.
Creating your first custom function
We need to require the following classes and enums from the library.
Now, let’s extend the APIFunction
class.
We will make an owoify
function for this example.
Now, let’s export your custom function.
Loading your custom function
To load your custom function, you can use the load
method of the function manager.
Scoped-functions Advanced
Scoped-functions are functions that can be executed in certain function scopes.
This is appliable for $case
and $switch
or canvas functions.
This is an easy-to-understand concept, but first,
we need to comprehend what an scope is.
Understanding scopes
“Scopes” refer to the contexts in which variables are accessible.
Let’s define a global variable.
You can access this variable in the whole code.
You change the value of a variable in a child scope and it will updated in the parent scope.
Now, let’s define an scoped variable.
Some functions can’t inherit data from parent scopes.
Creating the parent function
You can follow the existing guide for this step in “Creating your first custom function”.
Creating the scoped function
Using our custom function