-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(PUI): document events and how we use them
We use a document message bus system for handling front end events, here is some quick documentation on how to use it.
- Loading branch information
1 parent
0c9f7fe
commit d0702ad
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/*doc | ||
--- | ||
title: Event Handling | ||
name: event_handling | ||
categories: | ||
- css_base_eventhandling | ||
--- | ||
Event handling in our system is handled through a document level message bus. | ||
This system works by publishing events when a component performs an action and | ||
letting that action bubble up to the `document`. If another component needs to | ||
interact with the first component, it can listen for that component's events | ||
at the `document` level. | ||
Example: | ||
Component π£ has a method `π₯`. In the code, you might see: | ||
<code class="pam"> | ||
π£.prototype.π₯ = function(blaze){ | ||
//do things | ||
// this represent the element the component is referring to | ||
$(this).trigger("π£:π₯"); | ||
}; | ||
</code> | ||
In another component π°, we have a method π. We know that when the π£ | ||
component has the π₯ method called, the π° component needs to call the π | ||
method. | ||
<code class="pam"> | ||
$(document).on("π£:π₯", function(){ | ||
π°.π(); | ||
}); | ||
</code> | ||
*/ |