Modules



Overview

When creating your own modules, there are three different build architectures to choose from:

  • Object Functions - These are re-usable objects that you return a new instance every time they are called. This is useful for re-usable utility components like notifications etc...
  • Singletons - Singletons are objects that are instantiated once and globally unique. This is useful for utility modules that require a single instance.
  • DOM Module - DOM Module are "special" singletons that are instantiated/re-instantiated any time the DOM is manipulated and or refreshed.


Object Functions

Below is an example of a simple object function style module. Notice that the arguments are passed to object constructor when the module is required.




Singletons

Below is an example of a simple singleton style module. Notice that the arguments are passed to object constructor when the module is defined.




DOM Modules

Below is an example of a simple dom style module. Notice that the arguments are passed to object constructor when the module is defined.