ember-async-component

1.0.11 • Public • Published

ember-async-component

This ember addon is used for building promise aware container components which handles success, loading and error states. This component also works seemlessly with ember-cli-fastboot

Compatibility

  • Ember.js v3.16 or above
  • Ember CLI v2.13 or above
  • Node.js v10 or above

Installation

ember install ember-async-component

Usage

This is the suspense component which be used to by container components when making API calls in a component. This component handles server side rendering issues and loading and error states out of the box for the consumer

@param {Function|object} [promise] Required promise for the component to render the loading, success and error state @param {boolean} [blockRender] Default is false. Used for deciding if the fastboot server should wait for the API call to complete

<Suspense
 @promise={{this.promise}}
 @blockRender={{false}}
 as |task|
>
 {{#if task.isLoading}}
   Loading...
 {{else if task.isSuccess}}
   {{task.data.userRequest.name}}: {{task.data.userRequest.time}}
 {{else if task.isError}}
   Error occurred: {{task.errorReason}}
 {{/if}}
</Suspense>

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

/ember-async-component/

    Package Sidebar

    Install

    npm i ember-async-component

    Weekly Downloads

    14

    Version

    1.0.11

    License

    MIT

    Unpacked Size

    12.8 kB

    Total Files

    12

    Last publish

    Collaborators

    • lukecoy
    • aliasmac
    • sunishsheth