Skip to content
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

Merged
merged 2 commits into from May 15, 2017
Merged

Maker: boardConnected() block #15109

merged 2 commits into from May 15, 2017

Conversation

islemaster
Copy link
Contributor

Add a boardConnected() function to Maker Toolkit that returns true when running with a connected board, and false when running without a board.

Part of the Let app run without a connected board feature. Preceded by #15022.

@@ -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);
Copy link
Contributor Author

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';
Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, nice! 👍

@islemaster islemaster merged commit 120f737 into staging May 15, 2017
@islemaster islemaster deleted the maker-board-connected-block branch May 15, 2017 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants