Class Creation
Notice: Be sure to read up on the [Packaging] system before reading this section.
There are four functions provided with OopJs that you can use to create a class.
- $abstract_class - A class that meant to be inheriting, but not constructed.
- $dynamic_class - Instances of the class are not sealed, and can have members added dynamically.
- $final_class - A class that has no subclass, and must be constructed.
- $public_class - An ordinary class that can be constructed or extended.
Each function has the same syntax, and is called within a package definition.
$public_class('ClassName', ['BaseClass',] function ClassDef($) {})
Where:
- 'ClassName' is a string representation of the class, and is how other classes refer to this class. This should also be the name of the javascript file for the class.
- 'BaseClass' is an optional string referencing an imported class you wish to extend. The current class will inherit properties and methods defined in the base class.
- ClassDef is a function that is called for each instance of a class, and accepts one argument as a way to reference internal members.
This internal object provides the following data:
- Any imported classes.
- Members defined on the current package. (internal)
- Members from it's inherited base class. (protected)
- members assigned to the class contructor. (static)