<commit_before># Hydra.js
Hidra.js is a module manager oriented system.

## Description

Hydra is used to create a scalable, maintainable and module oriented system.
Hydra is framework agnosthic.
Hydra has been designed to create your application in a modular design system.

### Some benefits:

* No known module to other modules
 * If something is wrong in one module, the others modules will continue working.
* Notifying an action will be called on all the modules that will be listening this action.
* A module can be extended
 * If you have a module that is working well you can extend it to change his behavior without losing is original behavior.
* Can be used in url threaded application as in a ajax threaded application.
* You can test your modules with any Unit Testing Framework.
* Only 1.1kb when Gzipped.

[API documentation](https://github.com/tcorral/Hydra.js/examples_and_documents/jsdoc/index.html)

[Examples](https://github.com/tcorral/Hydra.js/examples_and_documents/index.html) to see for yourself!

## Usage

### Before using it:
Insert in your code:

	<script type="text/javascript" src="/path/to/your/js/libs/Hydra.js"></script>
	
### Create a module
	Hydra.module.register('moduleId', function(action)
	{
		return {
			init: function (oData) {},
			handleAction: function (oNotifier){
			},
			destroy: function () {}
		};
	});

### Extend a module
To extend a module you will need to register the base module before extend it.

	Hydra.module.extend('moduleId', function(action)
	{
		return {
			init: function (oData) {},
			handleAction: function (oNotifier){
			},
			destroy: function () {}
		};
	});

### Listening actions
To use the action manager you have accessible using "action".

*Tip: Use it on your init to start listening actions when the module starts.*

#### One action
	Hydra.module.register('moduleId', function(action)
	{
		return {
			init: function (oData) {
				action.listen(['action1'], this.handleAction, this);
			},
			handleAction: function (oNotifier){
			},
			destroy: function () {}
		};
	});

#### More actions
	Hydra.module.register('moduleId', function(action)
	{
		return {
			init: function (oData) {
				action.listen(['action1', 'action2'], this.handleAction, this);
			},
			handleAction: function (oNotifier){
				switch(oNofitier.type)
				{
					case 'action1':
						/* your code */
						break;
					case 'action2':
						/* your code */
						break;
					default: break;
				}
			},
			destroy: function () {}
		};
	});
	
*Tip: If you have several actions to listen I recommend to make use of an object where the keys must be the names of the actions.*

	Hydra.module.register('moduleId', function(action)
	{
		return {
			init: function (oData) {
				action.listen(['action1', 'action2', 'actionN'], this.handleAction, this);
			},
			actionHandlers: {
				action1: function (oData) {},
				action2: function (oData) {},
				actionN: function (oData) {}
			},
			handleAction: function (oNotifier){
				var oHandler = this.actionHandlers[oNotifier.type]
				if(typeof oHandler === "undefined")
				{
					return;
				}
				oHandler.call(this, oData);
				oHandler = null;
			},
			destroy: function () {}
		};
	});

### Notifying actions
To use the action manager you have accessible using "action".

The notify method needs a Notifier object:

	var oNotifier = {
		type: 'listenedAction',
		data: 'data'
	};

*Tip: You can notify an action where ever you want inside the module using 'action'*

	Hydra.module.register('moduleId', function(action)
	{
		return {
			init: function (oData) {
				action.listen(['action1', 'action2', 'actionN'], this.handleAction, this);
				$("#button").click(function(){
					action.notify({
						type: 'listenedAction',
						data: 'data'
					});
				});
			},
			actionHandlers: {
				action1: function (oData) {},
				action2: function (oData) {},
				actionN: function (oData) {}
			},
			handleAction: function (oNotifier){
				var oHandler = this.actionHandlers[oNotifier.type]
				if(typeof oHandler === "undefined")
				{
					return;
				}
				oHandler.call(this, oData);
				oHandler = null;
			},
			destroy: function () {}
		};
	});
*Tip: You can create an Action on your code to notify some module creating a new instance of it in this way:*

	var oAction = new (Hydra.action());
		oAction.notify({
			type: 'listenedAction',
			data: 'data'
		});

## Documentation

[API documentation](https://github.com/tcorral/Hydra.js/examples_and_documents/jsdoc/index.html)

[Examples](https://github.com/tcorral/Hydra.js/examples_and_documents/index.html) to see for yourself!

## License

Hydra.js is licensed under the MIT license.

## Agreements<commit_msg>Edited README.md via GitHub<commit_after># Hydra.js
Hidra.js is a module manager oriented system.

## Description

Hydra is used to create a scalable, maintainable and module oriented system.
Hydra is framework agnosthic.
Hydra has been designed to create your application in a modular design system.

### Some benefits:

* No known module to other modules
 * If something is wrong in one module, the others modules will continue working.
* Notifying an action will be called on all the modules that will be listening this action.
* A module can be extended
 * If you have a module that is working well you can extend it to change his behavior without losing is original behavior.
* Can be used in url threaded application as in a ajax threaded application.
* You can test your modules with any Unit Testing Framework.
* Only 1.1kb when Gzipped.

(Links will only work if you clone the repo)
[API documentation](https://github.com/tcorral/Hydra.js/examples_and_documents/jsdoc/index.html)

[Examples](https://github.com/tcorral/Hydra.js/examples_and_documents/index.html) to see for yourself!

## Usage

### Before using it:
Insert in your code:

	<script type="text/javascript" src="/path/to/your/js/libs/Hydra.js"></script>
	
### Create a module
	Hydra.module.register('moduleId', function(action)
	{
		return {
			init: function (oData) {},
			handleAction: function (oNotifier){
			},
			destroy: function () {}
		};
	});

### Extend a module
To extend a module you will need to register the base module before extend it.

	Hydra.module.extend('moduleId', function(action)
	{
		return {
			init: function (oData) {},
			handleAction: function (oNotifier){
			},
			destroy: function () {}
		};
	});

### Listening actions
To use the action manager you have accessible using "action".

*Tip: Use it on your init to start listening actions when the module starts.*

#### One action
	Hydra.module.register('moduleId', function(action)
	{
		return {
			init: function (oData) {
				action.listen(['action1'], this.handleAction, this);
			},
			handleAction: function (oNotifier){
			},
			destroy: function () {}
		};
	});

#### More actions
	Hydra.module.register('moduleId', function(action)
	{
		return {
			init: function (oData) {
				action.listen(['action1', 'action2'], this.handleAction, this);
			},
			handleAction: function (oNotifier){
				switch(oNofitier.type)
				{
					case 'action1':
						/* your code */
						break;
					case 'action2':
						/* your code */
						break;
					default: break;
				}
			},
			destroy: function () {}
		};
	});
	
*Tip: If you have several actions to listen I recommend to make use of an object where the keys must be the names of the actions.*

	Hydra.module.register('moduleId', function(action)
	{
		return {
			init: function (oData) {
				action.listen(['action1', 'action2', 'actionN'], this.handleAction, this);
			},
			actionHandlers: {
				action1: function (oData) {},
				action2: function (oData) {},
				actionN: function (oData) {}
			},
			handleAction: function (oNotifier){
				var oHandler = this.actionHandlers[oNotifier.type]
				if(typeof oHandler === "undefined")
				{
					return;
				}
				oHandler.call(this, oData);
				oHandler = null;
			},
			destroy: function () {}
		};
	});

### Notifying actions
To use the action manager you have accessible using "action".

The notify method needs a Notifier object:

	var oNotifier = {
		type: 'listenedAction',
		data: 'data'
	};

*Tip: You can notify an action where ever you want inside the module using 'action'*

	Hydra.module.register('moduleId', function(action)
	{
		return {
			init: function (oData) {
				action.listen(['action1', 'action2', 'actionN'], this.handleAction, this);
				$("#button").click(function(){
					action.notify({
						type: 'listenedAction',
						data: 'data'
					});
				});
			},
			actionHandlers: {
				action1: function (oData) {},
				action2: function (oData) {},
				actionN: function (oData) {}
			},
			handleAction: function (oNotifier){
				var oHandler = this.actionHandlers[oNotifier.type]
				if(typeof oHandler === "undefined")
				{
					return;
				}
				oHandler.call(this, oData);
				oHandler = null;
			},
			destroy: function () {}
		};
	});
*Tip: You can create an Action on your code to notify some module creating a new instance of it in this way:*

	var oAction = new (Hydra.action());
		oAction.notify({
			type: 'listenedAction',
			data: 'data'
		});

## Documentation

(Links will only work if you clone the repo)
[API documentation](https://github.com/tcorral/Hydra.js/examples_and_documents/jsdoc/index.html)

[Examples](https://github.com/tcorral/Hydra.js/examples_and_documents/index.html) to see for yourself!

## License

Hydra.js is licensed under the MIT license.

## Agreements
{'fraction_non_alphanumeric': 0.1253968253968254, 'fraction_numerical': 0.0031746031746031746, 'mean_word_length': 3.524174246050742, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '158789', 'n_tokens_mistral': 3405, 'n_tokens_neox': 2897, 'n_words': 934}