more info on on-start

This commit is contained in:
Peli de Halleux 2017-01-19 17:51:48 -08:00
parent 51ebc29887
commit 28830aa905
2 changed files with 11 additions and 1 deletions

View File

@ -2,6 +2,10 @@
### @description Language constructs for the Block editor. ### @description Language constructs for the Block editor.
Blocks snap into each other to define the program that your @boardname@ will run.
Blocks can be event (buttons, shake, ...) or need to be snapped into an event to run.
The [on-start](/blocks/on-start) event runs first.
```namespaces ```namespaces
for (let i = 0;i<5;++i) {} for (let i = 0;i<5;++i) {}
if (true){} if (true){}

View File

@ -16,7 +16,13 @@ input.onButtonPressed(Button.A, () => {
led.setBrightness(50) led.setBrightness(50)
``` ```
## What about JavaScript? ## What about JavaScript?
``on-start`` only exists in the block editor. In JavaScript, all code executes sequentially from the first line. ``on-start`` only exists in the block editor. In JavaScript, all code executes sequentially from the first line.
## Hey, my events moved!
When we transform the blocks into JavaScript, we always place all the event registrations (buttons, shake, ...)
before launching the ``on start`` code.
If a block from ``on start`` pauses, other registered events will have the opportunity to run as well.