Dispatch Custom Events: $dispatch
Learn to dispatch custom events using the $dispatch magic property.
We'll cover the following...
We'll cover the following...
We use the $dispatch magic property to dispatch custom browser events:
When we type into the input field, the custom log-me event (line 6) is dispatched. The @log-me listener then catches it and logs the input field’s value to the console.
Pass data to $dispatch
We can also pass data to the listener with the dispatched event. Then, the event object will have a property called .detail, which contains whatever data we passed. Let’s see an ...