esf-javascript-core

EsFramework Javascript core. Contains simple classloader, heavily inspired by ExtJs

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,
 
    constructorfunction (a) {
        // Save var 
        this.= a;
 
        // Heyho 
        console.log('A');
    },
    foofunction (b) {
        console.log('foo - ' + b);
    }
});
 
Esf.define('B', {
    b: null,
 
    constructorfunction (ab) {
        // Call super constructor 
        this.callParent(a);
 
        // Save var 
        this.= b;
 
        // Heyho 
        console.log('B');
    },
    foofunction () {
        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();