esf-javascript-core
v0.2.4
Published
EsFramework Javascript core. Contains simple classloader, heavily inspired by ExtJs
Downloads
12
Readme
This is a lightweight classloader that is heavily inspired by the Ext.ClassManager. To keep it simple there are no additional dependencies. See esf-web-core package for dynamicaly loading files by json etc.
Installation
Browser:
<script type="text/javascript" src="lib/core.js" />
Node-JS:
$ npm install esf-javascript-core
Todo
- Add multiple inheritance
- Add tags
- Add singletons
- Add private, protected, static methods
- Add namespace mapping
- Create more meanfull error messages
- Create test cases
Simple example
Esf.define('A', {
a: null,
constructor: function (a) {
// Save var
this.a = a;
// Heyho
console.log('A');
},
foo: function (b) {
console.log('foo - ' + b);
}
});
Esf.define('B', {
b: null,
constructor: function (a, b) {
// Call super constructor
this.callParent(a);
// Save var
this.b = b;
// Heyho
console.log('B');
},
foo: function () {
this.callParent('bar');
}
}, {
extend: 'A'
});
// Use
var b = new B(1, 2);
// or
var b = Esf.create('B', 1, 2);
/*
* Output:
* A
* B
* foo - bar
*/
b.foo();