Home User Documentation Developer Documentation GitHub

Namespace: dependencyManager

plastic.modules. dependencyManager

Dependency Manager (Singleton)

The Dependency Manager is used to keep track which dependencies are needed to load every plastic element on the page It can (lazy)load those dependencys on demand and manages the according events.

Members

staticplastic.modules.dependencyManager.registry

Registry Object that collects all extnal dependencies by name, and ressources

If a module is added that has a new external dependency it can either be added here or be added via setDependency() at runtime. If "test" is given, plastic.js will look if the given global variable exists. If it does, it will not be loaded.

staticplastic.modules.dependencyManager.usedDeps

Object of all Ressources that have to be loaded

Methods

staticplastic.modules.dependencyManager.add(dependencyArray)

modules/dependencyManager.js, line 93

Add a dependency that has to be loaded

Name Type Description
dependencyArray Array

Array of dependency names (has to fit with the registry above)

staticplastic.modules.dependencyManager.fetch()

modules/dependencyManager.js, line 117

Fetches all external dependencies asyncronally

Dependencies to load have to be added first via .add(dependencies) Triggers plastic events (loaded-)

Uses https://github.com/rgrove/lazyload/

TODO
  • Dependency Caching?

staticplastic.modules.dependencyManager.getDependency(dep){Object}

modules/dependencyManager.js, line 83

Gets a dependency Object by name

Name Type Description
dep string

staticplastic.modules.dependencyManager.missingDependency(test){boolean}

modules/dependencyManager.js, line 159

Checks if Dependency is already loaded. Supports three types of checks:

  • Global Browser Functions
  • jQuery Global Functions
  • jQuery Element Functions
Name Type Description
test string

staticplastic.modules.dependencyManager.setDependency(depName, jsArray, cssArray)

modules/dependencyManager.js, line 64

Sets a new dependency (that isn't registered yet)

Name Type Description
depName string

Dependency Name

jsArray Array optional

Array of JavaScript Files to load (optional)

cssArray Array optional

Array of CSS Files to load (optional)