51

The Lightning Components Cheat Sheet lists a few common $A functions and the Lightning Components Developer Guide references some others that are useful for certain situations. I can view the $A object in the JavaScript console and get a list of a whole lot more, including some nested such as the $A.util functions.

Is there documentation on the $A functions that are part of the published API (i.e., safe to use)?

4
  • I don't think its a matter of whether they're "safe to use" so much as the fact they're Aura, or a Top Level JavaScript Application as opposed to being in-line JavaScript that's part of the regular DOM.
    – crmprogdev
    Oct 23, 2014 at 12:44
  • 1
    @crmprogdev SFDC uses a ton of JavaScript, a lot of which is not supported and should not be referenced in our apps. They also have some such as the canvas/publisher JS and the JS referenced in the docs I mentioned. I consider those that are documented to be part of their published API that they will support by adhering to the contracts of the function/objects. I'd consider those safe for me to use in my app as any change made that breaks the API would not be allowed. This is opposed to the undocumented functions that I can get from the JavaScript console and reverse engineer. Oct 23, 2014 at 13:58
  • 1
    Thank you for clarifying your question Peter. I didn't pick up on that nuance from the way you phrased your question. You've asked an excellent question in distinguishing between what currently "works", yet isn't documented in the SF API, and whether it's safe to use it in Aura Apps. Will be interesting to see what answers you receive.
    – crmprogdev
    Oct 23, 2014 at 14:47
  • 1
    @PeterKnolle Sorry, I couldn't edit your post directly, so I'll do it through a comment: There's a type in your first link, 'Lightening', which points to a dead link. If you change it to Lightning it goes to the correct pdf.
    – Folkert
    Jun 8, 2016 at 7:38

2 Answers 2

49

Answering my own question. The Lightning Components Developer's Guide has the following:

The Aura object is the top-level object in the JavaScript framework code. For all the methods available in the Aura class, see the JavaScript API at https:/[mySalesforceInstance].lightning.force.com/auradocs/reference.app, where [mySalesforceInstance] is the name of the instance hosting your org; for example, na1.

So you can go to https://na15.lightning.force.com/auradocs/reference.app for example and see something like the following: Aura ($A) object docs

3
  • 5
    Please use caution when exploring the JS API. There are a lot of things that are used by the framework, but which aren't really useful when developing components.
    – Skip Sauls
    Oct 24, 2014 at 20:05
  • 1
    What shows up on this list will be filtered soon to only include those items we plan for customers to use. The rest may change or be removed so you want to be wary of using anything from this for now.
    – Kris Gray
    Apr 23, 2015 at 14:39
  • Are all these available over sf1 app as well?
    – SEuser
    Jun 21, 2016 at 11:23
7

Here is some $A.util usage

// Find a component where you wan to apply the util
var myAttr = component.find("myAttr"); 
$A.util.addClass(myAttr, "add-class");

Similarly

getBooleanValue
hasClass
isArray
isEmpty
isObject
isUndefined
isUndefinedOrNull
removeClass
toggleClass

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .