Lightning Component Interfaces

In this blog, I am going to explain lightning component interfaces. Other OOP programming like Java, Apex etc lightning component has Object-oriented support to define the interface that defines a set of signatures. Salesforce has the lot of marker interface to implement for the different purpose like app builder and quick action and ext. Similar you can define your own interfaces. An interface starts with the <aura:interface> tag. It can only contain these tags:
<aura:attribute> tags to define the interface’s attributes.
<aura:registerEvent> tags to define the events that it may fire.
<aura: method> tags to define the events that it may fire.
You can’t use markup, renderers, controllers, or anything else in an interface. 

Define an interface panelType.intf the developer console with below code

when a component implements an interface all attributes, methods, and events will be available by the compiler in the background, so the attributes will be available at runtime – say no need to really ‘implement’ the contract from the interface by yourself.If you can see the above interface which contains the methods and attributes and events which are going to implement from the component with below code.

controller

helper

 

Now the component is having two show and hide action the first show and hide actions are coming from the methods of the interface and components has inherited those methods by implementing the paneltype.intf interface and Second show and hide actions are firing from the events which are again coming from the interface and component is inherited those events by implementing the paneltype.intf interface.