-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: Add public API for setting event dispatcher #139
Conversation
// noinspection JSUnusedGlobalSymbols | ||
setEventDispatcher(eventDispatcher: EventDispatcher) { | ||
this.eventDispatcher = eventDispatcher; | ||
} |
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.
i really don't love these mutable setter APIs we have in the EppoClient
, as a fan of immutable data types, i'd much rather do it like that, but I'm following the existing pattern here
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.
Agreed, anything that won't toggle after instantion should be constructor options and immutable
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.
that would be a bigger refactoring, so maybe we can consider for a future major release
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.
Looking good to me although you've really pissed off the linter 😝
// noinspection JSUnusedGlobalSymbols | ||
setEventDispatcher(eventDispatcher: EventDispatcher) { | ||
this.eventDispatcher = eventDispatcher; | ||
} |
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.
Agreed, anything that won't toggle after instantion should be constructor options and immutable
return this.queue.length === 0; | ||
} | ||
|
||
[Symbol.iterator](): IterableIterator<T> { |
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.
Your ruby is bleeding into typescript 😛
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.
lol this is actually part of the standard typescript API :) maybe they were inspired by ruby 🤣
@@ -198,4 +201,26 @@ describe('DefaultEventDispatcher', () => { | |||
expect(global.fetch).toHaveBeenCalled(); | |||
}); | |||
}); | |||
|
|||
describe('newDefaultEventDispatcher', () => { |
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.
🙌
if (!config.ingestionUrl) { | ||
throw new Error('Missing required ingestionUrl in EventDispatcherConfig'); | ||
} | ||
if (!config.deliveryIntervalMs) { | ||
throw new Error('Missing required deliveryIntervalMs in EventDispatcherConfig'); | ||
} | ||
if (!config.retryIntervalMs) { | ||
throw new Error('Missing required retryIntervalMs in EventDispatcherConfig'); | ||
} | ||
if (!config.maxRetryDelayMs) { | ||
throw new Error('Missing required maxRetryDelayMs in EventDispatcherConfig'); | ||
} | ||
} |
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.
Minor, but this could probably be made into a loop to simplify.
thanks for the review 🙏🏽 |
Fixes: FF-3604
Motivation and Context
Description
This change accomplishes mainly 2 things:
EventDispatcher
into theEppoClient
DefaultEventDispatcher
instance via factory functionHow has this been tested?
Wrote tests