dcl
is coming: dcl6
. This is an experimental version written from the ground up specifically to take advantage of new ES6 language features: new class
keyword, new super
mechanism. The implementation uses symbols to keep innards truly private.
The principal coding has been finished several months ago, and the new library was under extensive real-world testing. Missing features: debug
module is unfinished, and the documentation is in early stages. So right now it is only for brave developers, who feel comfortable reading tests and the code to understand the changed API, and who are not afraid to encounter possible bugs.
Logically, it is based on dcl 2.x branch and supports all advanced ES5 features as well. Of course, it supports chaining and AOP advices we all come to love. It even provides the same set of advices, mixins, and utilities. As before, it has no external dependencies, and minimal in size.
So how does it look?
Example: ES6 features with tracing advices.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
Example: inherit built-in classes. (Yes, we finally can do that in ES6! And they do behave properly, down to “magic” properties!)
1 2 3 4 5 |
|
Example: chaining directives.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
Example: post-construction.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
dcl6
is being hosted in a separate repository: https://github.com/uhop/dcl6 At the moment it is not on npm
, so the only way to play with it is to clone the repo.
dcl
can be used with projects based on ES6. Unfortunately some tools had problems with dcl
in a certain configuration:
dcl
uses strict ES5 subset.To make dcl
more Babel-friendly so it can be easily used in React-based projects, or any projects, where tooling is based on webpack, new distribution was introduced: /es6/
.
Starting with version 2.0.3 dcl
has a special directory /es6/
, which contains processed modules with dependencies done in the ES6 style with import
statements. They expose their APIs with export default
.
This feature is modeled after /dist/
directory, which hosts processed modules with browser global-based dependencies ready to be included with <script>
or concatenated with other browser-ready files.
In order to use dcl
in your ES6-based project just import its modules like that:
1 2 3 4 5 |
|
dcl
in 2.0.2: registry.
Registry automatically collects all newly-declared constructors, if they define declaredClass
property. Later they can be accessed by names. This feature is useful to decouple a declaration of a constructor from places that use it, and for debugging purposes. It provides a Map-like API, so users can inspect and manipulate the registry.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
dcl.prop()
.
configurable
, enumerable
, and writable
.detectProps
mode can detect property descriptors in-line without decorators.require()
import, and AMD are supported out of box.At the same time it continues to support successful familiar features:
Version 1.x is still supported and will continue to be available for legacy browsers.
Check out the full documentation. Use the installation guide to start using the new dcl
in your projects.
This is a minor release, which can be safely skipped by most users.
]]>This update can be safely skipped by most users, yet I advise to test it against your codebase, because it will serve as a foundation for the upcoming major version.
]]>dcl
(1.1.1) includes two minor bug fixes:
Most users can safely skip this update, unless they are directly affected by the monkey-patch bug.
]]>legacy.js documentation contains all necessary background information for the change, and recommendations on how to use it in real projects.
Changes:
]]>The version bump was required in order to add dcl
to bower — a generic, unopinionated solution to the problem of front-end package management. If you use Bower to manage your project dependencies, you can install dcl
like this:
1
|
|
dcl
it was not called when creating an object. This bug is fixed and relevant
tests were added.This update is about maintenance. It doesn’t introduce new features. Given that
the fixed bug is quite exotic, this update can be skipped unless your code contains
a mix of dcl
and non-dcl
bases and mixins in the same constructor functions.
dcl
was added to jam — the RequireJS-based package manager
for front-end projects. If you use jam to manage your project dependencies, you can install dcl
like this:
1
|
|
new Function
were replaced with function(){}
to bypass Content Security Policy restrictions,
because new Function
even without any parameters is considered to be eval
(???), and forces to allow eval
globally.This update doesn’t affect any functionality, and can be safely skipped, if you don’t work with security-constrained environments.
]]>dcl
,
he agreed, and here we go:
Introduction to dcl.
If you don’t read David’s blog regularly, and you are serious about web applications, you are missing out. He frequently publishes very interesting articles on JavaScript, CSS, new development in browsers, and so on. Check out his tutorials, demos, and in-depth articles. Get yourself in the know.
]]>call()
or apply()
to specify its instance.dcl
exceptions.<script>
inclusion.So far dcl
has proved to be fairly stable, no major bugs were found.
Almost all changes in 1.0.1 are backward-compatible, and upgrading to it
should be transparent.
The only non-compatible change is export names with <script>
tags,
which are not recommended anyway – when in browser please use an AMD
loader like RequireJS.
dcl
is out
in the open.
What is dcl
? It is a micro library for OOP/AOP. It works in
node.js and modern browsers, supports AMD, and completely
open source.
If you plan to use it in your node.js project install it like this:
1
|
|
For your browser-based projects I suggest to use volo.js:
1
|
|
It is licensed under BSD or AFLv2 (your choice), all contributions are legally clean and covered by CLA, so you can use it not only for pet projects, but at work too.
For more information hop on what is dcl? and learn more. Do not forget to look at extensive documentation, or shoot me an email, if you still have more questions.
]]>