API Docs for: 0.0.1
Show:

commonjs.Module Class

Defined in: commonJS\module.js:11
Module: window

the module class for the commonjs to manage the modules for the application

Constructor

commonjs.Module

()

Methods

excute

(
  • type=''
)
Object public

excute the module. because the module just was registered in module management center before excuting it.

Parameters:

  • type='' String

    the slogan to indicate when to excute this module, the value has 2 types: '~'/default. '~' will excute it in document.ready; and the others will be excuted right now!

Returns:

Object: the module

excuteit

() Object private

the internal implement for the method of excute. it will get all the required modules, and excute the facotry of this module. and store the result to the property exprots

Returns:

Object: the module

getExports

() Object public

it will get the export of the modules . if the factory hasn't been excuted, it will execute the factory of this module by call this.excuteit().

Returns:

Object: the exports of this module

getRequireList

(
  • list
)
Array private

it will get all the required modules .

Parameters:

  • list Array

    the required modules' name of this instance

Returns:

Array: the array of all the required modules

init

(
  • id
  • [req]
  • factory
)
Object public

the initial entry for this Module,and it will be excuted immediately when the instance is created! The params are from the function of Module.createInstace(id,req,factory);

Parameters:

  • id String

    the module name for the instance, it should be unique and the namspace is expected like 'mywork/module1'

  • [req] Array optional

    the required modules for this module

  • factory Function

    the factory function for the module

Returns:

Object: an instance of Module

Properties

exports

Object public

store the exports of this module

Default: null

id

String public

the unique id for the module

Default: ''

requiredList

Array public

store the names of all the required modules

Default: []