 Hello, everyone. I'm Sanjay Gupta. I welcome you on Sanjay Gupta Tech School in this module. I'm going to demonstrate how you can implement application event while creating lightning or a component. Let's start understanding application event. So if you want to implement application event and lightning or a component. So you need to implement three things first you to you need to implement application event. Then you need to create two components so that one component will be firing the event and another will be handling that. So, as you know, the comparison between component and application event if you have watched my previous module recording on that topic. So in component event basically it happens in parent child hierarchy, but in application, like whenever any component fires and events that goes to the application, and then whoever component is want to handle that component. Sorry that event so that component can handle that application event. If you want to create application event file so you can go here lightning event and this event type will be application and here you can create the attribute. Now, you need to create new lightning component so I'm going to name it as app event notifier. So here first you need to register the application event and then this component will be firing the event and another component that will be available in the application that will be handling that application event. So I'm going to register it so our column register event then name equals to app event then type equals to C colon application event. Then we need to use one heading and inside heading. We can use application event notify. We're going to use a UI button and its label will be fire application event. And this is the method that will be executed whenever we will be clicking on this button. Right so so this is app event notifier component. Sorry, this is by mistake open. Okay, so here I have just created a button and if you click on that button. So this fire app event method will be executed. Now what we need to do, we need to implement this fire app event method definition. So I'm just moving to controller. So this components controller will be having the code related to that method so I'm just based in that method name here. And inside that controller. Now I need to implement the method definition so that whenever you execute. So what statements will be executed. So I'm just creating a variable app event. Then dollar a dot get E dot C colon application even so it is different from component event so in component even we just use this event, but in application event you need to use dollar a dot get and E dot C colon then application event name. You can use this app event variable to set the parameters. So parameters we need to set these like we have a parameter message so we need to set its value here. So masses and value from location event notifier, then app event dot fire. So what is happening here. The initial event information is available. And through this variable I'm setting the parameter value so parameter is like masses which is defined as attribute here. And this value will be assigned into this message and this event will be fired through this statement. Right. So, this way we created one component that will be registering the event and will be firing the event as well. So I need to create one more lightning component. So this is this component will be app event handler. So in this component we will be handling that application even that is being fired from the component. So I just need to create or attribute name equals to masses from notifier type equals to string, then or handler event equals to C colon application event and action equals to see dot handle app event. So this way basically I handled that application event, and when that event will be fired so in this component, this method will be executed and in this method, the statements will be available for handling that application event. Okay, so now after this statement, I'm just creating one at one time. And here I'm writing the masses application event handler so that we can recognize. So both are independent components. And there is no parent child relationship between these components, right. You need to remember like if you want to pass any masses from child to parent then you will be using component event but if you want to fire any event or if you want to pass message from a component to any other component inside the application. So in that case you can use application event. So here I'm going to use this V dot masses from notifier. So I'm just pasting it here. So this way my app event handler component view is implemented. Now I'm going to define this method. So I'm just copying its name. And inside this controller I just need to define this method. Here I'm going to create a variable masses equals to even dot get param. So here I need to write the name of the parameter so basically in your application event the parameter or attribute name is masses so we need to use that here. So I'm going to use component dot set V dot this message from notifier this attribute and I just need to pass the masses. So this way in this components controller. Basically, this value is passed. I just saved it so here you can see we have to these two components app event notifier and app event handler. Now I just need to create one more component that will be known as container component. So I'm creating a container and in that container I will be calling these two. Right so here I'm writing C colon app event notifier and C colon app event handler. So this way both are available together in a container. Now if notifier is firing any event so if handler wants to handle that even so that that component can handle that. So now after this container component you can use your application so I'm just opening demo application. And inside this demo application I'm going to use container. And I'm saving this application and clicking on preview. So through that container component both the components will be rendered here. So at top you can see application event notifier. And bottom you can see application event handler. So if I click on this button so this button click will fire and fire an application event and on firing of that application event value will be passed to application event that will be fetched through this component which is handler. So if I click on this button so you can see masses is available here. Right, so this way in your application from one component to any other component if you want to pass the masses. So in that case, you can use this application event.