Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An ability to run $A.createComponent() functionality using Promise API manner #3

Closed
ruslan-kurchenko opened this issue Dec 20, 2017 · 1 comment
Labels

Comments

@ruslan-kurchenko
Copy link
Owner

ruslan-kurchenko commented Dec 20, 2017

It would be nice to have an ability to create components dynamically with Promise API.

Here is the official documentation about this functionality with raw callback approach: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/js_cb_dynamic_cmp_async.htm

Below is a rough example of the implementation usage:

component.lax.createComponent(
  'lightning:button',
  {
    'aura:id': 'saveBtn',
    'label': 'Save',
    'onclick': component.getReference('c.onClickSave')
  }
)
.then(button => {
  const body = component.get('v.body');
  body.push(button);
  component.set('v.body', body);
})
.catch(error => {
  console.log("Error: " + error);
});

.createComponent(), .then() and .catch() fuctions must return LaxPromise object.
The API should be similar to server-side actions functionality.
Users will have an ability to chain several components creation:

component.lax.createComponent()
  .then(firstComponent => {
    return component.lax.createComponent(...)
  })
  .then(secondComponent => {
    // custom logic here
  })
  .catch(error => {
    console.log("Error: " + error);
  });

Note: The same functionality should be implemented to create a list of components - $A.createComponents(definitions)

@ruslan-kurchenko ruslan-kurchenko changed the title An ability to run $A.createComponent() functionality using Builder Pattern manner An ability to run $A.createComponent() functionality using Promise API manner Dec 20, 2017
@ruslan-kurchenko
Copy link
Owner Author

Released in v1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant