Lightning Component Event Handling :
Event Firing is the way to communicate between components in salesforce lightning
There are two types of Event in lightning :
1: Component Event 
2: Application Event

Event Firing for Component Event works by firing the event and all event handler in the component hierarchy receives the event

In lightning component event handling invovles registering events and handling events

Event Firing :


Declare event 

<aura:registerEvent name="any event name" type="c: Event created name"/>

Then fire this event in js :
var compEvent = component.getEvent("DemoCompEventName"); //get the event
compEvent.setParams({});
compEvent.fire(); // firing event

Event Handling :
Component Events are handling only by elements that are above the event fired component ie : If grandchild fired, it's parent, grand parent can receive the event

<aura:handler name="event handle name " event="c: Event name "
    action="{!c. handler action name }"  />

Name - the name must be same as the registerEvent Name
action - action should be the same action method present in the handler component
event - must match the same type as the event that fired
    
The below program shows an hello world for Component event handling and firing

Create the Lightning Event as below  and save it as DemoEmptyCompEvent

<aura:event type="Component" description="Event template" >
</aura:event>

Create Lightning Component and name it as EventFiringChild_Cmp

<!--


 * created by 		:		Shiva RV
 * Date				:		13-10-2018
 * Description		:		Hello World Comp Event Firing Child
  
-->

<aura:component >
    <!-- Register Event in the component which fires the event -->
    <aura:registerEvent name="DemoCompEventName" type="c:DemoEmptyCompEvent"/>

	<lightning:button label = "FireEvent" variant="brand" onclick = "{!c.handleClick}" />

</aura:component>
 EventFiringChild_Cmp Js Controller Code:
({
	handleClick : function(component, event, helper) {
        //use the event name in the registered event to get the event in js
		var compEvent = component.getEvent("DemoCompEventName");
        //better to set empty param attribute's even though the event has no attributes
        compEvent.setParams({});
		compEvent.fire();
        console.log("component event is fired ");
	}
})

Create Lightning Component and name it as CompEventHandlingParent

Note that the child component is instantiated in parent and onclick of the childcomponent button ,an event is fired

<!--
 * created by 		:		Shiva RV
 * Date				:		13-10-2018
 * Description		:		Hello World Comp Event Handling Parent
  
-->
<aura:component >
    <!-- For component event , handler name must be same as registered Event -->
	<aura:handler name="DemoCompEventName" event="c:DemoEmptyCompEvent"
    action="{!c.handleComponentEvent}"  />
    
    <!-- place the child component so as to make the event fire happening -->
    <c:EventFiringChild_Cmp></c:EventFiringChild_Cmp>
</aura:component>
EventFiringChild_Cmp Js Controller Code:
({
	handleComponentEvent : function(component, event, helper) {
		alert("congrats , we have captured the component event ");
	}
})
Below is the hello world App code:
<!--


 * created by 		:		Shiva RV
 * Date				:		13-10-2018
 * Description		:		Hello World Lighting App
  
-->

<aura:application extends="force:slds">
<!-- Component Event Firing and handling Eg -->
    <c:CompEventHandlingParent></c:CompEventHandlingParent> 
</aura:application>
Output:
Key Notes :
*In this tutorial you can find the way to fire lightning component events and handle them
*The event bubbles up in the contaiment heirarchy (That from component child it reaches till root)
Will explain dom event cycle in depth in later chapter .
*It is always good practise to use Component Event whenever possible