0.0.83 • Published 10 years ago

dynel-core v0.0.83

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

Dynamic Elements - Core Framework

Build Status Code Climate

Dynamic Elements is a JavaScript framework for building modular component-based applications. It can be used for building both web applications or Node.js applications.

  • The Core Framework provides the basic building blocks of a Dynamic Elements application.
  • The Data Framework builds on the Core Framework for classes to work with business data, including model objects with well-defined data types, and collections.
  • The UI Framework provides support for building UI elements for your web applications that can be tied to your business data.

Getting Started

To get started using Core Framework in a Node.js application, you just need to install the dynel-core package and it's dependencies:

npm install dynel-core

Core Framework provides the building blocks for building functional components, using a combination of classical inheritance and composition using mixins.


CoreObject and Classical Inheritance

Dynamic Elements classes are derived from CoreObject. The following example demonstrates how to create a derived class from CoreObject:

var CoreObject = require('dynel-core').CoreObject;

var HelloWorld = CoreObject.extend({
    className: 'HelloWorld',

run: function() {
	console.log('Hello World!');
}
});

var hello = new HelloWorld();
hello.run();

Mixins and Composition

Dynamic Elements classes support components called mixins, which add state and/or functionality to an object. Mixins are plain old JavaScript objects.

The following example demonstrates how to create a class that is composed of multiple mixins:

var Hello = {
	hello: function() {
		console.log('Hello ');
	}
};
var World = {
    world: function() {
		console.log('World!');
	}
};


 var HelloWorld = CoreObject.extend({
	className: 'HelloWorld',
	
	mixins: [
		Hello,
		World
	],
	
	run: function() {
		this.hello();
		this.world();
	}
});

var hello = new HelloWorld();
hello.run();

Mixins can also be composed of other mixins:

var Hello = {
	hello: function() {
		console.log('Hello ');
	}
};
var World = {
    mixins: [ 
	Hello
    ],
    world: function() {
		console.log('World!');
	}
};

 var HelloWorld = CoreObject.extend({
	className: 'HelloWorld',
	
	mixins: [
		World
	],
	
	run: function() {
		this.hello();
		this.world();
	}
});

var hello = new HelloWorld();
hello.run();

Event Sources

The Core Framework includes a mixin for listening for and emitting events. It is similar to the Node.js EventEmitter, but is designed as a simple mixin that can be added to Dynamic Elements objects.

var EventSource = require('dynel-core').EventSource;

var HelloWorld = CoreObject.extend({
className: 'HelloWorld',

    mixins: [
  EventSource 
],

run: function() {
	this.emit('HelloWorld', 'Hello World!');
}
});

var hello = new HelloWorld();
hello.on('HelloWorld', function(data) {
   console.log(data);
});
hello.run();
0.0.83

10 years ago

0.0.82

10 years ago

0.0.81

10 years ago

0.0.80

10 years ago

0.0.79

10 years ago

0.0.78

10 years ago

0.0.77

10 years ago

0.0.76

10 years ago

0.0.75

10 years ago

0.0.74

10 years ago

0.0.73

10 years ago

0.0.72

10 years ago

0.0.71

10 years ago

0.0.70

10 years ago

0.0.69

10 years ago

0.0.68

10 years ago

0.0.67

10 years ago

0.0.66

10 years ago

0.0.62

10 years ago

0.0.61

10 years ago

0.0.60

10 years ago

0.0.59

10 years ago

0.0.58

10 years ago

0.0.57

10 years ago

0.0.56

10 years ago

0.0.55

10 years ago

0.0.54

10 years ago

0.0.53

10 years ago

0.0.52

10 years ago

0.0.51

10 years ago

0.0.50

10 years ago

0.0.49

10 years ago

0.0.48

10 years ago

0.0.47

10 years ago

0.0.46

10 years ago

0.0.45

10 years ago

0.0.44

10 years ago

0.0.43

10 years ago

0.0.42

10 years ago

0.0.41

10 years ago

0.0.40

10 years ago

0.0.39

10 years ago

0.0.38

10 years ago

0.0.37

10 years ago

0.0.36

10 years ago

0.0.35

10 years ago

0.0.34

10 years ago

0.0.33

10 years ago

0.0.32

10 years ago

0.0.31

10 years ago

0.0.30

10 years ago

0.0.29

10 years ago

0.0.28

10 years ago

0.0.27

10 years ago

0.0.26

10 years ago

0.0.25

10 years ago

0.0.23

10 years ago

0.0.21

10 years ago

0.0.20

10 years ago

0.0.18

10 years ago

0.0.17

10 years ago

0.0.16

10 years ago

0.0.15

10 years ago

0.0.14

10 years ago

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

11 years ago

0.0.9

11 years ago

0.0.8

11 years ago

0.0.7

11 years ago

0.0.4

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago