β
Yesterday, we learned how to connect a child and parent Web Component to each other. Today, we're going to look at how to use custom events to provide a more decoupled experience. Let's dig in! π€« Shhh! I'm working on a new workshop-style course on Web Components. I don't even have a landing page for it yet, but if you buy my All-Access Pass, you'll get instant access to it as soon as its ready. Custom eventsThe Pass in the event type as an argument. You can optionally provide an object as a second argument, with details about whether or not the event Then, you run the
You can then listen for the event with the
There are a lot of different naming conventions you can use, but for library events, I like to use a For example, I might name the event that's emitted when the Next button is clicked in the Emitting our Web Component eventIn the
We can also remove Back in the
Then, we'll handle the event by running
Use events generouslyIf I were building this out as a real Web Component, I'd probably emit a I'd include the
For example, you could use this to create some additional UI that displays the current box number that's highlighted, like 1 of 3. Like this? You can support my work by purchasing an annual membership. Cheers, β Want to share this with others or read it later? View it in a browser.β β |
Beranda Β» Tanpa Label Β» [Go Make Things] How to get different Web Components to talk to each other (part 2)
Related Post:
- Almost done
- FBI Top Stories: Director Wray Champions FBI Before House Judiciary Committee
- Co-Director of Think Tank Indicted for Acting as Unregistered Foreign Agent, Trafficking in Arms, Violating U.S. Sanctions Against Iran, and Making False Statements to Federal Agents
- We've Added Another Speaker: What's Speed Got to do With it: Speed Management Strategies
- Our Favorite Budget Mattress Is $170 Off
0 Komentar untuk "[Go Make Things] How to get different Web Components to talk to each other (part 2)"