-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prefer for..of loops to forEach for perf #32
Conversation
const execution = fn(payload); | ||
// Emit errors if fn returns promise that rejects | ||
(execution as Promise<any>)?.catch?.((e) => { | ||
if(event === Lifecycle.error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing I don't like about this PR is the redundancy here. Lines 709-717 are the same as 724-734.
I thought about pulling this error logic into a function to eliminate the redundancy, but I wanted to avoid the overhead of creating a closure when we hit the happy path.
src/strongbus_spec.ts
Outdated
@@ -798,6 +798,22 @@ describe('Strongbus.Bus', () => { | |||
}); | |||
}); | |||
|
|||
it('raises "error" when the listener returns a promise that rejects', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This spec is old behavior, but I didn't see it previous captured by a spec.
const error = new Error('Error in callback'); | ||
bus.on('bar', () => { | ||
throw error; | ||
describe('error events', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these new specs are just capturing existing behavior. They all pass against the master
branch.
No description provided.