Lesson 10 of 21 · Components
Events
A child tells its parent about a change with an event. event declares it, emit sends it, and the parent listens with on:.The compiler checks the types of an event in both files, so a wrong name is a compile error.Your turn
- In Stepper.surf, add the event event changed(by: Int);.
- Send emit changed(1) from the first button, and emit changed(-1) from the second.
- In App.surf, listen with on:changed={by => total += by}.
Preview
1 error
The sandbox needs a browser.