new LaxPromise()
- Source:
The container of the actual context promise.
It helps to call chain function (then
, catch
)
in the Aura context. The client can avoid of $A.getCallback
calls.
Methods
catch(onError) → {LaxPromise}
- Source:
Attaches a callback for only the rejection of the Promise.
Example
component.lax.enqueue('c.save', { record: record })
.then(id => {
component.set('v.record.id', id);
})
.catch(errors => {
console.error(errors);
});
Parameters:
Name | Type | Description |
---|---|---|
onError |
function | The callback to execute when the Promise is rejected. |
Returns:
A LaxPromise for the completion of the callback.
- Type
- LaxPromise
error(onError) → {LaxPromise}
- Source:
Attaches a callback for only the rejection of the Promise and for only actions that returns "ERROR" state
Parameters:
Name | Type | Description |
---|---|---|
onError |
function | The callback to execute when the Promise is rejected. |
Returns:
A LaxPromise for the completion of the callback.
- Type
- LaxPromise
finally(callback) → {LaxPromise}
- Source:
The method returns a LaxPromise. When the Promise is settled, whether fulfilled or rejected, the specified callback function is executed. This provides a way for code that must be executed once the Promise has been dealt with to be run whether the promise was fulfilled successfully or rejected.
This lets you avoid duplicating code in both the promise's then() and catch() handlers.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | The function to run whe the Promise is settled |
Returns:
- Type
- LaxPromise
incomplete(onIncomplete) → {LaxPromise}
- Source:
Attaches a callback for only the rejection of the Promise and for only actions that returns "INCOMPLETE" state
Parameters:
Name | Type | Description |
---|---|---|
onIncomplete |
function | The callback to execute when the Promise is rejected. |
Returns:
A LaxPromise for the completion of the callback.
- Type
- LaxPromise
then(onSuccess, onErroropt) → {LaxPromise}
- Source:
Attaches callbacks for the resolution and/or rejection of the Promise.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
onSuccess |
function | undefined | The callback to execute when the Promise is resolved. |
|
onError |
function |
<optional> |
The callback to execute when the Promise is rejected. |
Returns:
A LaxPromise for the completion of which ever callback is executed.
- Type
- LaxPromise