I've been trying to use the Async/Await
syntax in my LC's controllers/helpers, but I haven't been able to. All kinds of ugly errors appear, such as this:
Error:(1, 1) FIELD_INTEGRITY_EXCEPTION - 0Ad9E0000009vA3: org.auraframework.util.json.JsonStreamReader$JsonStreamParseException: Invalid literal value [36, 21]: 'async': Source
They way I have been trying to implement this feature is:
myHelperMethod: async function( param 1 ){
}
Are you guys aware of any way of implementing it or is it not possible at all? Browsers do support it, which is what encouraged me, but maybe the framework doesn't allow it.
Best Answer
There is NO other option to define action handlers (client-side controllers, helpers or renderers) except with the
function
keyword:Handling Events with Client-Side Controllers
Using
async function
keyword anywhere in Lightning Components is not allowed, because currently, Lightning Components support only ES6 features, whileasync/await
is an ES8 feature. Arrow functions=>
can be used as callbacks.