Register new module on the core instances.

Syntax registerModule(name, constructor [, init])

Return Type undefined


Register new module on the core instances. Using this method, you can extend oCanvas with more modules that will be instantiated on every new core instance.


name : String
The name of the module. This module will be accessible from core.thisname.
constructor : Function
A function that returns an object with all the properties and methods of your module.
init : String
Name of a method on the object that the constructor returns. This method will be called each time a new core instance is created. Optional.

Return Value

undefined. Doesn't return anything.


Example 1

We start by defining the constructor function. That function will immediately return the object we specify. After the constructor block we run the method registerModule() and pass the constructor variable into that method. The module is now registered and will be instantiated for each new core instance. Next, we create a new core instance and output the value of the foo property in our new module. Note: The function output() used in this example is a custom function only for this example and is not part of oCanvas.

View Example
var constructor = function () {
	return {
		foo: "foobar"

oCanvas.registerModule("myModule", constructor, "init");

var canvas = oCanvas.create({
	canvas: "#canvas",
	background: "#ccc"