Skip to content
Maurits edited this page Oct 7, 2018 · 1 revision

Hooks allow you to intercept and/or mutate data in different parts of the SIMPLOO code.

The following hooks are available:

  • beforeInstancerInitClass
    • Called before a class definition is turned into an instantiatable object. You can modify the classFormat to change the class.
    • Arguments: (classFormat)
    • Useful for things like: automatically add getter/setter methods to classes
  • afterInstancerInitClass
    • Called after a class definition has been turned into an instantiatable object.
    • Arguments: (classFormat, classInstance)
  • afterInstancerInstanceNew
    • Called every time an instance is made using the Class.new() method.
    • Arguments: (newInstance)
  • onSyntaxNamespace
    • Called every time a namespace statement is used.
    • Arguments: (namespaceName)
  • onSyntaxUsing
    • Called every time a using statement is used.
    • Arguments: (namespaceName)
    • Useful for things like: lazy load the file of a class when it's being used

Example of how to create a hook:

simploo.hook:add("beforeInstancerInitClass", function(classFormat)
    -- modify your class format here
end)
Clone this wiki locally