Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rename EventEmitter to SequentialExecutor

  • Loading branch information...
commit 6e20551e4a3e528d29b236fb4c7207a3f7cbd417 1 parent 6f63a7e
@lsegal lsegal authored
View
2  lib/config.js
@@ -15,7 +15,7 @@
var AWS = require('./core');
require('./event_listeners');
-require('./event_emitter');
+require('./sequential_executor');
require('./metadata_service');
var inherit = AWS.util.inherit;
View
8 lib/core.js
@@ -46,7 +46,7 @@ AWS.util.update(AWS, {
require('./config');
require('./http');
-require('./event_emitter');
+require('./sequential_executor');
require('./event_listeners');
require('./request');
require('./client');
@@ -57,8 +57,8 @@ require('./metadata_service');
/**
* @readonly
- * @return [AWS.EventEmitter] a collection of global event listeners that are
- * attached to every sent request.
+ * @return [AWS.SequentialExecutor] a collection of global event listeners that
+ * are attached to every sent request.
* @see AWS.Request AWS.Request for a list of events to listen for
* @example Logging the time taken to send a request
* AWS.events.on('send', function startSend(resp) {
@@ -70,4 +70,4 @@ require('./metadata_service');
*
* new AWS.S3.Client().listBuckets(); // prints 'Request took 0.285 seconds'
*/
-AWS.events = new AWS.EventEmitter();
+AWS.events = new AWS.SequentialExecutor();
View
14 lib/event_listeners.js
@@ -14,7 +14,7 @@
*/
var AWS = require('./core');
-require('./event_emitter');
+require('./sequential_executor');
require('./service_interface/json');
require('./service_interface/query');
require('./service_interface/rest');
@@ -83,7 +83,7 @@ AWS.EventListeners = {
};
AWS.EventListeners = {
- Core: new AWS.EventEmitter().addNamedListeners(function(add, addAsync) {
+ Core: new AWS.SequentialExecutor().addNamedListeners(function(add, addAsync) {
addAsync('VALIDATE_CREDENTIALS', 'validate',
function VALIDATE_CREDENTIALS(req, doneCallback) {
req.client.config.getCredentials(function(err) {
@@ -262,35 +262,35 @@ AWS.EventListeners = {
}),
- Json: new AWS.EventEmitter().addNamedListeners(function(add) {
+ Json: new AWS.SequentialExecutor().addNamedListeners(function(add) {
var svc = AWS.ServiceInterface.Json;
add('BUILD', 'build', svc.buildRequest);
add('EXTRACT_DATA', 'extractData', svc.extractData);
add('EXTRACT_ERROR', 'extractError', svc.extractError);
}),
- Rest: new AWS.EventEmitter().addNamedListeners(function(add) {
+ Rest: new AWS.SequentialExecutor().addNamedListeners(function(add) {
var svc = AWS.ServiceInterface.Rest;
add('BUILD', 'build', svc.buildRequest);
add('EXTRACT_DATA', 'extractData', svc.extractData);
add('EXTRACT_ERROR', 'extractError', svc.extractError);
}),
- RestJson: new AWS.EventEmitter().addNamedListeners(function(add) {
+ RestJson: new AWS.SequentialExecutor().addNamedListeners(function(add) {
var svc = AWS.ServiceInterface.RestJson;
add('BUILD', 'build', svc.buildRequest);
add('EXTRACT_DATA', 'extractData', svc.extractData);
add('EXTRACT_ERROR', 'extractError', svc.extractError);
}),
- RestXml: new AWS.EventEmitter().addNamedListeners(function(add) {
+ RestXml: new AWS.SequentialExecutor().addNamedListeners(function(add) {
var svc = AWS.ServiceInterface.RestXml;
add('BUILD', 'build', svc.buildRequest);
add('EXTRACT_DATA', 'extractData', svc.extractData);
add('EXTRACT_ERROR', 'extractError', svc.extractError);
}),
- Query: new AWS.EventEmitter().addNamedListeners(function(add) {
+ Query: new AWS.SequentialExecutor().addNamedListeners(function(add) {
var svc = AWS.ServiceInterface.Query;
add('BUILD', 'build', svc.buildRequest);
add('EXTRACT_DATA', 'extractData', svc.extractData);
View
4 lib/request.js
@@ -224,7 +224,7 @@ AWS.Request = inherit({
this.params = params || {};
this.httpRequest = new AWS.HttpRequest(endpoint, region);
- AWS.EventEmitter.call(this);
+ AWS.SequentialExecutor.call(this);
},
/**
@@ -397,7 +397,7 @@ AWS.Request = inherit({
}
});
-AWS.util.mixin(AWS.Request, AWS.EventEmitter);
+AWS.util.mixin(AWS.Request, AWS.SequentialExecutor);
/**
* This class encapsulates the the response information
View
20 lib/event_emitter.js → lib/sequential_executor.js
@@ -23,11 +23,11 @@ var AWS = require('./core');
*
* @param eventName [String] the event name to register the listener for
* @param callback [Function] the listener callback function
- * @return [AWS.EventEmitter] the same object for chaining
+ * @return [AWS.SequentialExecutor] the same object for chaining
*/
-AWS.EventEmitter = AWS.util.inherit({
+AWS.SequentialExecutor = AWS.util.inherit({
- constructor: function EventEmitter() {
+ constructor: function SequentialExecutor() {
this._events = {};
},
@@ -132,12 +132,12 @@ AWS.EventEmitter = AWS.util.inherit({
/**
* Adds or copies a set of listeners from another list of
- * listeners or EventEmitter object.
+ * listeners or SequentialExecutor object.
*
- * @param listeners [map<String,Array<Function>>, EventEmitter]
+ * @param listeners [map<String,Array<Function>>, AWS.SequentialExecutor]
* a list of events and callbacks, or an event emitter object
* containing listeners to add to this emitter object.
- * @return [AWS.EventEmitter] the emitter object, for chaining.
+ * @return [AWS.SequentialExecutor] the emitter object, for chaining.
* @example Adding listeners from a map of listeners
* emitter.addListeners({
* event1: [function() { ... }, function() { ... }],
@@ -146,10 +146,10 @@ AWS.EventEmitter = AWS.util.inherit({
* emitter.emit('event1'); // emitter has event1
* emitter.emit('event2'); // emitter has event2
* @example Adding listeners from another emitter object
- * var emitter1 = new AWS.EventEmitter();
+ * var emitter1 = new AWS.SequentialExecutor();
* emitter1.on('event1', function() { ... });
* emitter1.on('event2', function() { ... });
- * var emitter2 = new AWS.EventEmitter();
+ * var emitter2 = new AWS.SequentialExecutor();
* emitter2.addListeners(emitter1);
* emitter2.emit('event1'); // emitter2 has event1
* emitter2.emit('event2'); // emitter2 has event2
@@ -157,7 +157,7 @@ AWS.EventEmitter = AWS.util.inherit({
addListeners: function addListeners(listeners) {
var self = this;
- // extract listeners if parameter is an EventEmitter object
+ // extract listeners if parameter is an SequentialExecutor object
if (listeners._events) listeners = listeners._events;
AWS.util.each(listeners, function(event, callbacks) {
@@ -242,4 +242,4 @@ AWS.EventEmitter = AWS.util.inherit({
* {on} is the prefered method.
* @api private
*/
-AWS.EventEmitter.prototype.addListener = AWS.EventEmitter.prototype.on;
+AWS.SequentialExecutor.prototype.addListener = AWS.SequentialExecutor.prototype.on;
View
8 test/event_emitter.spec.coffee → test/sequential_executor.spec.coffee
@@ -13,8 +13,8 @@
AWS = require('../lib/core')
-describe 'AWS.EventEmitter', ->
- beforeEach -> @emitter = new AWS.EventEmitter()
+describe 'AWS.SequentialExecutor', ->
+ beforeEach -> @emitter = new AWS.SequentialExecutor()
describe 'addListeners', ->
it 'accepts a hash of events and functions', ->
@@ -35,9 +35,9 @@ describe 'AWS.EventEmitter', ->
@emitter.emit('otherEventName')
expect(triggers).toEqual([1, 1, 1])
- it 'accepts an EventEmitter object', ->
+ it 'accepts a SequentialExecutor object', ->
triggers = [0, 0, 0]
- listeners = new AWS.EventEmitter()
+ listeners = new AWS.SequentialExecutor()
listeners.on 'eventName', -> triggers[0] = 1
listeners.on 'eventName', -> triggers[1] = 1
listeners.on 'otherEventName', -> triggers[2] = 1
Please sign in to comment.
Something went wrong with that request. Please try again.