Skip to content

Commit

Permalink
fix(index): handle errors per callback invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
StrahilKazlachev committed Nov 21, 2016
1 parent 3fb7cc0 commit dc7819f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,24 @@ export class EventAggregator {
subscribers = subscribers.slice();
i = subscribers.length;

try {
while (i--) {
while (i--) {
try {
subscribers[i](data, event);
} catch (e) {
logger.error(e);
}
} catch (e) {
logger.error(e);
}
}
} else {
subscribers = this.messageHandlers.slice();
i = subscribers.length;

try {
while (i--) {
while (i--) {
try {
subscribers[i].handle(event);
} catch (e) {
logger.error(e);
}
} catch (e) {
logger.error(e);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions test/event-aggregator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ describe('event aggregator', () => {

ea.subscribe('dinner', crash);
ea.subscribe('dinner', callback);
ea.subscribe('dinner', crash);

ea.publish('dinner', data);

Expand Down

0 comments on commit dc7819f

Please sign in to comment.