Skip to content

Commit

Permalink
chore(PUI): document events and how we use them
Browse files Browse the repository at this point in the history
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
jefflembeck committed Apr 12, 2016
1 parent 0c9f7fe commit d0702ad
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/pivotal-ui/components/events/events.scss
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>
*/

0 comments on commit d0702ad

Please sign in to comment.