Skip to content

Instantly share code, notes, and snippets.

View paustint's full-sized avatar
🏠
Working from home

Austin Turner paustint

🏠
Working from home
View GitHub Profile
{
"pass": true
}
@paustint
paustint / sfdc-lightning-debounce-helper
Created March 3, 2018 00:32
Salesforce Lightning: debounce helper method
({
debounce: function(func, wait, immediate) {
var timeout;
return $A.getCallback(function() {
var context = this,
args = arguments;
var later = function() {
timeout = null;
if (!immediate) {
func.apply(context, args);
// utils.resource
window.utils = ({
foo: function() {
console.log('HELLO, WORLD!');
},
})
<ltng:require scripts="{!$Resource.utils}" afterScriptsLoaded="{!c.doInit}"/>
<!-- If you had an init handler remove it, as we don't want to initialize until our scripts are loaded -->
<!-- <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> -->
// utils.resource
window.utils = ({
SHOW_LOG: true, // Set to false in production
log: function() { },
warn: function() { },
error: function() { },
logInit: function () {
if(this.SHOW_LOG) {
({
// example helper function
getQuoteLines: function(component, quoteId, quoteLineId) {
return new Promise(function (resolve, reject) {
var action = component.get("c.getQuoteLines");
action.setCallback(this, function(results) {
utils.log('getQuoteLines() results', results);
if(results.getState() === 'SUCCESS') {
<aura:component description="DebounceExample" controller="DebounceExampleController">
<!--External resources, we are using the join() function in case other resources are needed in the future-->
<ltng:require scripts="{!join(',', $Resource.lodash)}" afterScriptsLoaded="{!c.doInit}" />
<aura:attribute name="searchedAccounts" type="List" default="[]" />
<aura:attribute name="selectedAccount" type="Object" />
<aura:handler name="ComboBoxChangedEvent" event="c:ComboBoxChangedEvent" action="{!c.handleComboBoxChangedEvent}"/>
<c:ComboBox
({
handleComboBoxChangedEvent: function(component, event, helper) {
var params = event.getParams();
if(params.type === 'searchTermChanged') {
component.set('v.comboLoading', true);
helper.searchAccounts(component, params.searchTerm)
.then(function(data) {
({
searchAccounts: function(component, searchTerm, localFranchiseAcctId) {
return new Promise(function (resolve, reject) {
// Get jobs from controller
var action = component.get("c.searchAccounts");
action.setParams({
searchTerm: searchTerm,
});
/**
*
* @description Data models for interacting with Steelbrick CPQ
* // https://community.steelbrick.com/t5/Developer-Guidebook/Public-API-Technical-Documentation-amp-Code-1/ta-p/5690
*
*/
public without sharing class CPQ_ApiDataModels {
/** INPUT PAYLOADS */