DCL

An elegant OOP with mixins + AOP for JavaScript.

Installation

Version 2.x

dcl can be installed with most popular package managers:

1
npm install --save [email protected]
1
yarn add [email protected]

When the package is installed, you can refer to individual files mentioned in the documentation.

dcl uses UMD, so it can be used by node as is. AMD loaders (used in browsers) are supported out of box too. If you prefer to use globals in your project, just source dcl from /dist/ directory:

1
<script src='node_modules/dcl/dist/dcl.js'></script>

For ES6-based projects, especially ones using Babel (e.g, React, or anything webpack-based), starting with 2.0.3 the special distribution is generated in /es6/ directory, which can be used like that:

1
2
import dcl from 'dcl/es6/dcl';
import advise from 'dcl/es6/advise';

Alternatively, you can use https://unpkg.com/ with AMD:

1
<script src='https:[email protected]/dcl.js'></script>

or globals:

1
<script src='https:[email protected]/dist/dcl.js'></script>

You can always find the latest code in github.com/uhop/dcl, and copy necessary files manually, or clone the whole project, if you wish.

Globals

Here is the full list of global names used by a version in /dist/ directory:

File name Comment Main global
dcl.js main OOP + AOP + chains dcl
advise.js object-level AOP advise
debug.js debugging dcl
advices/counter.js advice dcl.advices.counter
advices/flow.js advice dcl.advices.flow
advices/memoize.js advice dcl.advices.memoize
advices/time.js advice dcl.advices.time
advices/trace.js advice dcl.advices.trace
bases/Mixer.js base “class” dcl.bases.Mixer
bases/Replacer.js base “class” dcl.bases.Replacer
mixins/Cleanup.js mixin dcl.mixins.Cleanup
mixins/Destroyable.js mixin dcl.mixins.Destroyable
utils/registry.js utility dcl.utils.registry