Skip to content

findhit/findhit-evented

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Evented test-badge

javascript chained event emitter based on findhit-class

Instalation

	npm install findhit-evented --save

Usage

var Evented = require('findhit-evented');

var events = new Evented();
events.on('test', function () { console.log( arguments ); });
events.fire( 'test', { hello: 'world' } );

// OR

var Socket = new Evented({

		initialize: function ( host, port ) {

			this.host = host;
			this.port = port;

		},

		connect: function () {
			var self = this;

			/*
				... some I/O
			*/

			this.fire( 'connecting' );

			// Maybe async?
				self.fire( 'connected' );

			return this;
		},

	});

var socket = new Socket( 'localhost', 123456 );

socket
	.on( 'connecting', function () {
		console.log( 'Trying to connect...' );
	})
	.once( 'connected', function () {
		console.log( 'YUPI' );
	})
	.connect();

About

javascript evented built on top of findhit-class

Resources

License

Stars

Watchers

Forks

Packages

No packages published