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
Maker: boardConnected() block #15109
Conversation
@@ -31,7 +31,7 @@ var stringBlockPrefix = 'str.'; | |||
// Configure shared APIs for App Lab | |||
// We wrap this because it runs before window.Applab exists | |||
function applabExecuteCmd(...args) { | |||
Applab.executeCmd.call(Applab, ...args); | |||
return Applab.executeCmd.call(Applab, ...args); |
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.
Was alarmed to discover that we were dropping App Lab command return values here. This didn't show up because this helper is only used when we need to inject the executeCmd
method into shared APIs, like Maker - and none of those shared APIs were using return values yet! (The digitalRead
and analogRead
maker methods are actually native-async methods masquerading as synchronous in App Lab, so they use callbacks).
digitalRead, | ||
digitalWrite, | ||
injectBoardController, | ||
onBoardEvent, | ||
pinMode | ||
} from '@cdo/apps/lib/kits/maker/commands'; | ||
import CircuitPlaygroundBoard from '@cdo/apps/lib/kits/maker/CircuitPlaygroundBoard'; | ||
import FakeBoard from '@cdo/apps/lib/kits/maker/FakeBoard'; |
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.
Both CircuitPlaygroundBoard
and FakeBoard
are required to conform to the new MakerBoard
interface as of my last PR, and we're already stubbing the whole class, below - so I've swapped this test to depend on FakeBoard
which means fewer test dependencies and is equally valid for unit testing purposes.
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.
Hooray for interfaces in JavaScript! Where is the MakerBoard
interface defined?
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, with a suite of tests for checking conformance to the interface of course! 😉
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.
Which both FakeBoard and CircuitPlaygroundBoard use now.
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.
Ah, nice! 👍
Add a
boardConnected()
function to Maker Toolkit that returnstrue
when running with a connected board, andfalse
when running without a board.Part of the Let app run without a connected board feature. Preceded by #15022.