mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
EventStore should return a promise
This commit is contained in:
parent
1c864bead4
commit
303d091d7d
@ -1,10 +1,10 @@
|
||||
var util = require('util');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var Promise = require('bluebird'),
|
||||
util = require('util'),
|
||||
EventEmitter = require('events').EventEmitter;
|
||||
|
||||
function EventStore() {
|
||||
EventEmitter.call(this);
|
||||
}
|
||||
|
||||
util.inherits(EventStore, EventEmitter);
|
||||
|
||||
EventStore.prototype.create = function (eventType, user, eventData) {
|
||||
@ -16,7 +16,10 @@ EventStore.prototype.create = function (eventType, user, eventData) {
|
||||
data: eventData
|
||||
};
|
||||
|
||||
this.emit(event.type, event);
|
||||
return new Promise(function (resolve, reject) {
|
||||
this.emit(event.type, event);
|
||||
resolve();
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
module.exports = new EventStore();
|
@ -29,8 +29,9 @@ module.exports = function (app) {
|
||||
//Todo: error-msg: feature name is already in use
|
||||
res.status(403).end();
|
||||
} else {
|
||||
eventStore.create(eventType.featureCreated, user, newFeature);
|
||||
res.status(201).end();
|
||||
eventStore.create(eventType.featureCreated, user, newFeature).then(function() {
|
||||
res.status(201).end();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user