This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:event type="COMPONENT" description="Event template"> | |
<aura:attribute name="empData" type="Object" /> | |
</aura:event> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
handleMessage : function(component, event, helper) { | |
const param = event.getParam('empData'); | |
document.querySelector('#output').innerHTML += | |
`<p class="slds-p-horizontal_medium">- Account "${param.sobject.Name}" with Id ${param.sobject.Id} is ${param.event.type}!!</p>`; | |
console.log(`Account "${param.sobject.Name}" with Id ${param.sobject.Id} is ${param.event.type}!!`); | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" > | |
<!--Include EmpApiDemo child component and pass channel name to subscribe | |
ex: "/topic/AccountSpy" is my pushtopic channel name | |
once the event is fired, it will handled in handleMessage controller method --> | |
<c:EmpApiDemo channelName="/topic/AccountSpy" onEmpEvent="{!c.handleMessage}" /> | |
<!-- lightning card to display detail --> | |
<lightning:card footer="This component displays account changes using lightning:empApi component" | |
title="Account Spy" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
/** | |
* This function calls subscribe method of empApi component | |
* to receive events | |
* @author Manish Choudhari | |
* @version 1.0.0 | |
* */ | |
subscribe: function(component, event, helper) { | |
// Get the empApi component. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component access="global"> | |
<!-- ChannelName, which needs to subscribed --> | |
<aura:attribute name="channelName" type="String" required="true"/> | |
<!-- Save the reference of current subscription, which can be unsubscribe later on --> | |
<aura:attribute name="subscription" type="Object"/> | |
<!-- This event is fired when a component is destroyed. | |
Handle this event if you need to do custom cleanup when a component is destroyed.--> | |
<aura:handler name="destroy" value="{!this}" action="{!c.unsubscribe}"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LightningMapDemoController { | |
@AuraEnabled(cacheable=true) | |
public static List<CarWrapper> getAllCars(){ | |
List<Car__c> cars = [SELECT Id, Name, Available_For_Rent__c, Build_Year__c, | |
Mileage__c, Per_Day_Rent__c, | |
(SELECT Id, Name, City__c,Coordinates__Latitude__s, Coordinates__Longitude__s, | |
Country__c, Pin_Code__c, State__c, Street__c FROM Address__r) | |
FROM Car__c Limit 100]; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
/** | |
* Get all cars from server | |
* */ | |
getCars : function(component, helper) { | |
//Call server action to get events | |
var action = component.get("c.getAllCars"); | |
action.setCallback(this, function(response) { | |
var state = response.getState(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
/** | |
* Fetch car list on component initialization and | |
* generate datatable columns | |
* */ | |
doInit : function(component, event, helper) { | |
component.set('v.columns', [ | |
{label: 'Name', fieldName: 'Name', type: 'text'}, | |
{label: 'Build Year', fieldName: 'BuildYear', type: 'number'}, | |
{label: 'Rent/Day', fieldName: 'PerDayRent', type: 'currency', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" | |
controller="LightningMapDemoController" | |
access="global" > | |
<!-- datatable component attribute --> | |
<aura:attribute name="data" type="Object"/> | |
<aura:attribute name="columns" type="List"/> | |
<aura:attribute name="selectedRowsCount" type="Integer" default="0"/> | |
<aura:attribute name="maxRowSelection" type="Integer" default="5"/> | |