About Me

My photo
PLANO, Texas, United States

Thursday, April 15, 2021

Aura Interfaces

Interfaces define a component’s shape by defining attributes, events, or methods that any implementing component contains. 
  • To use an interface, a component must implement it.

  • An interface can’t be used directly in markup.

Types of Interfaces

Broadly, there are two types of Interfaces, one is in-build interface provided by framework which can be used for different and the other is a custom that developers can build themself.

In-build Interface

Theura framework provides in-build interfaces which you can implements in your custom component for different purposes. Below are a few in build interface:

  1. force:appHostable – The force:appHostable interface makes the component available for use as a custom tab. This interface is a marker interface. A marker interface is a signal to the component’s container to add the interface’s behavior to the component. You don’t need to implement any specific methods or attributes in your component, you simply add the interface name to the component’s implements attribute.

  2. flexipage:availableForAllPageTypes-To make your component available for record pages and any other type of page, implement the flexipage:availableForAllPageTypes interface.

  3. flexipage:availableForRecordHome- To make your component available for record pages only, implement the flexipage:availableForRecordHome interface.

  4. force:lightningQuickAction- Add the force:lightningQuickAction interface to a Lightning component to allow it to be used as a custom action

  5. forceCommunity:availableForAllPageTypes- To appear in Experience Builder, a component must implement the forceCommunity:availableForAllPageTypes interface.

  6. force:hasRecordId-Add the force:hasRecordId interface to an Aura component to enable the component to be assigned the ID of the current record. The current record ID is useful if the component is used on a Lightning record page, as an object-specific custom action or action override in Lightning Experience or the Salesforce mobile app, and so on. This interface has no effect except when used within Lightning Experience, the Salesforce mobile app, and Aura-based Experience Builder sites.

You can find more build interface below: https://developer.salesforce.com/docs/component-library/overview/interfaces 

Custom Interface

You can create your own interface using <aura:interface> tag. An interface can contain only 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.


<aura:interface>

    <aura:attribute name="value" type="String" />

    <aura:registerEvent name="onItemSelected" type="ui:response" description="The event fired when the user selects an item" />

    <aura:method name="methodFromInterface">

        <aura:attribute name="stringAttribute" type="String" default="default string" />

    </aura:method>

</aura:interface>


1 comment: