0.0.83 • Published 8 years ago

dynel-core v0.0.83

Weekly downloads
4
License
MIT
Repository
github
Last release
8 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

8 years ago

0.0.82

8 years ago

0.0.81

8 years ago

0.0.80

8 years ago

0.0.79

8 years ago

0.0.78

8 years ago

0.0.77

8 years ago

0.0.76

9 years ago

0.0.75

9 years ago

0.0.74

9 years ago

0.0.73

9 years ago

0.0.72

9 years ago

0.0.71

9 years ago

0.0.70

9 years ago

0.0.69

9 years ago

0.0.68

9 years ago

0.0.67

9 years ago

0.0.66

9 years ago

0.0.62

9 years ago

0.0.61

9 years ago

0.0.60

9 years ago

0.0.59

9 years ago

0.0.58

9 years ago

0.0.57

9 years ago

0.0.56

9 years ago

0.0.55

9 years ago

0.0.54

9 years ago

0.0.53

9 years ago

0.0.52

9 years ago

0.0.51

9 years ago

0.0.50

9 years ago

0.0.49

9 years ago

0.0.48

9 years ago

0.0.47

9 years ago

0.0.46

9 years ago

0.0.45

9 years ago

0.0.44

9 years ago

0.0.43

9 years ago

0.0.42

9 years ago

0.0.41

9 years ago

0.0.40

9 years ago

0.0.39

9 years ago

0.0.38

9 years ago

0.0.37

9 years ago

0.0.36

9 years ago

0.0.35

9 years ago

0.0.34

9 years ago

0.0.33

9 years ago

0.0.32

9 years ago

0.0.31

9 years ago

0.0.30

9 years ago

0.0.29

9 years ago

0.0.28

9 years ago

0.0.27

9 years ago

0.0.26

9 years ago

0.0.25

9 years ago

0.0.23

9 years ago

0.0.21

9 years ago

0.0.20

9 years ago

0.0.18

9 years ago

0.0.17

9 years ago

0.0.16

9 years ago

0.0.15

9 years ago

0.0.14

9 years ago

0.0.13

9 years ago

0.0.12

9 years ago

0.0.11

9 years ago

0.0.10

9 years ago

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.4

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago