Book Image

Learning Salesforce Lightning Application Development

By : Mohit Shrivatsava
Book Image

Learning Salesforce Lightning Application Development

By: Mohit Shrivatsava

Overview of this book

Built on the Salesforce App Cloud, the new Salesforce Lightning Experience combines three major components: Lightning Design System, Lightning App Builder, and Lightning Components, to provide an enhanced user experience. This book will enable you to quickly create modern, enterprise apps with Lightning Component Framework. You will start by building simple Lightning Components and understanding the Lightning Components architecture. The chapters cover the basics of Lightning Component Framework semantics and syntax, the security features provided by Locker Service, and use of third-party libraries inside Lightning Components. The later chapters focus on debugging, performance tuning, testing using Lightning Testing Services, and how to publish Lightning Components on Salesforce AppExchange.
Table of Contents (22 chapters)
Title Page
PacktPub.com
Foreword
Contributors
Preface
Index

ES6 support in Lightning Components


Lightning Components do not fully support ES6 syntax. However, a few important functions, such as Promise and array utilities, such as filter, map, and reduce functions, have been found to work, as of the current version.

An introduction to Promises

If you never need the capability to nest callbacks, your code can become difficult to debug and maintain. The following code snippet shows an example of nested callbacks (they are also commonly referred to as callback hell):

getUsers(function () {
    getUserDetail(function () {
        getProductsPurchasedByUser(function() {
            getRecommendedProducts(function () {

            });
        });
    });
});

The Promise API (https://developer.mozilla.Org/en-US/docs/Web/JavaScript/Guide/Using_promises) in JavaScript solves the problem of callback hell by returning the object that can attach callbacks, rather than passing the callback a the parameter.

The preceding code snippet for a nested callback can be written...