Callbacks
Callbacks are used to asynchronously communicate upwards the components tree and with other things like agents or the DOM during event handling. Internally their type is just an Fn wrapped in Rc to allow them to be cheaply cloned.
They have an emit function if you want to call them manually.
use ;
let cb: = from;
let result = cb.emit; // call the callback
// web_sys::console::log_1(&result.into()); // if uncommented will print "Bye Bob"
Passing callbacks as props#
A common pattern in yew is to create a callback and pass it down as a prop.
use ;
// Then supply the prop
DOM Events and Callbacks#
Callbacks are also used to hook into DOM events.
For example, here we define a callback that will be called when the user clicks the button:
use ;