Works on publish-subscribe model.
3 phases in Application Event Propagation:
Capture
Bubble
Default
Sequence of application event propagation:
1. Event fired.
2. Capture Phase
3. Bubble Phase
4. Default Phase
Importance of fire() method:
fire() is used to fire an event.
EVENTS BEST PRACTICES:
1. Use component Events whenever possible. Salesforce prefers <Component> more than <Application> if possible.
However you should know the difference:
Component follows a hierarchical model and can only be handled by components above them. And it uses a localised usage.
Application allows communication between components at applications level (no hierarchical model). So this is preferable when communication is required.
2. Seperate the low level events from business logic events
That means handle the low level events in event handler and refire them as higher level events.
3.Dynamic actions should be based on component state.
4. Using a dispatcher component to listen and relay events.
In case of large number of handler components listening for an event, dispatcher component can do some logic and fire components.
Comments
Post a Comment