-
Notifications
You must be signed in to change notification settings - Fork 45
Emit dial events rather than logging them #563
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
base: main
Are you sure you want to change the base?
Conversation
@@ -36,7 +37,7 @@ export class EventDispatcher { | |||
this.listeners[type]?.delete(listener); | |||
} |
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.
Why aren't we passing <T>
to once
, has
, and off
?
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.
Added to once
, can't think of any type safety added by the others can you?
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.
No, once
make sense.
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.
A few questions
// eslint-disable-next-line no-console | ||
console.debug('Reconnected successfully!'); | ||
this.emit(MachineConnectionEvent.DIAL_EVENT, { | ||
message: 'Reconnected successfully', |
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.
Why is this a DIAL_EVENT
and not CONNECTED
?
await client.connect({ | ||
priority: conf.priority, | ||
dialTimeout: conf.dialTimeout ?? DIAL_TIMEOUT, | ||
creds: conf.credentials, | ||
}); | ||
|
||
// eslint-disable-next-line no-console | ||
console.debug('connected via WebRTC'); | ||
client.emit(MachineConnectionEvent.DIAL_EVENT, { |
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.
Similarly, why is this a DIAL_EVENT
and not CONNECTED
?
@@ -9,21 +9,22 @@ export enum MachineConnectionEvent { | |||
CONNECTED = 'connected', | |||
DISCONNECTING = 'disconnecting', | |||
DISCONNECTED = 'disconnected', | |||
DIAL_EVENT = 'dialing', |
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.
Is DIALING
different than CONNECTING
?
Currently we don't allow end-users to consume dial events, we only log them to the JS console. Logging isn't a good idea for production apps because:
This PR improves both situations by instead having the RobotClient emit dial events, which we can present in UIs, and removing logs.