Skip to content

Building promise aware container components which handles success, loading and error states

License

Notifications You must be signed in to change notification settings

sunishsheth2009/ember-async-component

Repository files navigation

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.

About

Building promise aware container components which handles success, loading and error states

Resources

License

Stars

Watchers

Forks

Packages

No packages published