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)?

  • 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 '14 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. – Peter Knolle Oct 23 '14 at 13:58
  • 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 '14 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 '16 at 7:38
up vote 40 down vote accepted

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

  • 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 '14 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 '15 at 14:39
  • Are all these available over sf1 app as well? – Kaushik Ray Jun 21 '16 at 11:23

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

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.