-
Notifications
You must be signed in to change notification settings - Fork 37
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
Use EventTarget rather than the Node "events" module #1188
Conversation
Compiles but untried Forces us to remove the clean up in dispose so perhaps some kind of assertion should replace it.
Preview build will be at |
|
||
const buttonTest = | ||
"from microbit import *\nwhile True:\nif button_a.was_pressed():\ndisplay.show(Image.NO)"; | ||
const buttonTest = `from microbit import * |
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've corrected the indentation in these tests which surprised me when I saw them in failure screenshots (for reasons unrelated to the indentation).
const setSelectedFile = useCallback( | ||
(file: string) => { | ||
setSelection({ file, location: { line: undefined } }); | ||
}, | ||
[setSelection] | ||
); | ||
useEffect(() => { |
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 think this was a listener ordering thing. I've changed it to avoid making a state update at all.
@@ -49,9 +50,7 @@ export class MockDeviceConnection | |||
|
|||
async initialize(): Promise<void> {} | |||
|
|||
dispose() { | |||
this.removeAllListeners(); |
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.
We can't do this anymore as EventTarget doesn't have such API.
All listener add/removes are correctly paired except that in host.ts and a test, neither of which need to remove their listeners.
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.
LGTM.
This should amount no meaningful change but is a useful preliminary to extracting the device code for reuse.
Incorporates the only meaningful file from https://github.com/DerZade/typescript-event-target/ (with licence details) to save on the dependency.