new Lax()
- Source:
The action main object of the component that is used as a shared prototype across all lax components
created in the application. See init
function of the laxHelper.js where the lax assigned as prototype.
Methods
action(actionName) → {LaxActionBuilder}
- Source:
Creates the action linked to LaxActionBuilder by the provided name.
Example
component.lax
.action('c.getContact')
.setStorable()
.setParams({ id: recordId })
.setThen(contact => {
component.set('v.record', contact)
})
.setCatch(error => {
console.error(error);
})
.enqueue();
Parameters:
Name | Type | Description |
---|---|---|
actionName |
String | the name of the action (Apex controller method) |
Returns:
- Type
- LaxActionBuilder
createComponent(type, attributes) → {LaxPromise}
- Source:
Create a component from a type and a set of attributes. It accepts the name of a type of component, a map of attributes, and returns {LaxPromise} to assign a callback function to notify caller.
Example
lax.createComponent("aura:text",{value:'Hello World'})
.then(function(auraTextComponent){
// auraTextComponent - is an instance of aura:text containing the value Hello World
});
Parameters:
Name | Type | Description |
---|---|---|
type |
String | The type of component to create, e.g. "ui:button". |
attributes |
Object | A map of attributes to send to the component. These take the same form as on the markup,
including events |
Returns:
- Type
- LaxPromise
createComponents(components) → {LaxPromise}
- Source:
Create an array of components from a list of types and attributes. It accepts a list of component names and attribute maps, and returns {LaxPromise} to assign a callback function to notify caller.
Example
lax.createComponents([
["aura:text",{value:'Hello'}],
["ui:button",{label:'Button'}],
["aura:text",{value:'World'}]
])
.then(function(components) {
// components - is an array of 3 components
// 0 - Text Component containing Hello
// 1 - Button Component with label Button
// 2 - Text component containing World
});
Parameters:
Name | Type | Description |
---|---|---|
components |
Array | The list of components to create, e.g. |
Returns:
- Type
- LaxPromise
enqueue(actionName, params, options) → {LaxPromise}
- Source:
Enqueues the action by the name and with passed in params and options.
The function returns Promise, subsequently client can chain the actions
by assigning then
callbacks or handle the error by catch
callback.
Example
component.lax.enqueue('c.getContact', { id: recordId }, { background: true })
.then(contact => {
component.set('v.record', contact);
});
Parameters:
Name | Type | Description |
---|---|---|
actionName |
String | the name of the action (Apex controller method name) |
params |
[Object] the object that contains parameters for the action |
|
options |
[ActionOptions] the object with list of options for the action |
Returns:
- Type
- LaxPromise
enqueueAll(actions) → {LaxPromise}
- Source:
Enqueues the list of actions parallel. The function return Promise that subsequently can be used to chain callback. The success callback assigned on the Promise called after all actions ready and an error have not thrown.
Example
component.lax.enqueueAll([
// { name : '...', params: {...}, options: {...} }
{ name: 'c.getContacts' },
{ name: 'c.getAccounts' },
{ name: 'c.getOpportunities' }
])
.then(results => {
// results: [ [contacts], [accounts], [opportunities] ]
var contacts = results[0];
var accounts = results[1];
var opportunities = results[2];
});
Parameters:
Name | Type | Description |
---|---|---|
actions |
Array.<ActionProperties> |
Returns:
- Type
- LaxPromise
event(eventName) → {LaxEventBuilder}
- Source:
Creates an object with {LaxEventBuilder} prototype with the context event by provided name. The function apply Application and Component event name.
Parameters:
Name | Type | Description |
---|---|---|
eventName |
String | the name of the event |
Returns:
- Type
- LaxEventBuilder
lds(id) → {LaxDataService}
- Source:
Creates a container of actual Lightning Data Service object.
Parameters:
Name | Type | Description |
---|---|---|
id |
String | the aura:id of the |
Returns:
- Type
- LaxDataService