https://github.com/kellyselden/ember-async-action-container
An async state wrapper
https://github.com/kellyselden/ember-async-action-container
Last synced: 9 months ago
JSON representation
An async state wrapper
- Host: GitHub
- URL: https://github.com/kellyselden/ember-async-action-container
- Owner: kellyselden
- License: mit
- Created: 2018-04-24T05:25:54.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-25T21:44:03.000Z (over 7 years ago)
- Last Synced: 2025-02-12T03:16:08.600Z (9 months ago)
- Language: JavaScript
- Size: 275 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
ember-async-action-container
==============================================================================
[](https://badge.fury.io/js/ember-async-action-container)
[](https://travis-ci.org/kellyselden/ember-async-action-container)
An async state wrapper
Inspired by https://github.com/DockYard/ember-async-button
Installation
------------------------------------------------------------------------------
```
ember install ember-async-action-container
```
Usage
------------------------------------------------------------------------------
```hbs
{{#async-action-container
action=(action "myAction")
as |action promise|
}}
{{#if promise.isPending}}
Submitting
{{else}}
Submit
{{/if}}
{{/async-action-container}}
```
If you want reset state:
```hbs
{{#async-action-container
action=(action "myAction")
callback=(action (mut myPromise))
promise=myPromise
as |action promise|
}}
{{#if promise.isPending}}
Submitting
{{else if promise.isRejected}}
Submit again
{{else if promise.isFulfilled}}
Submitted
{{else}}
Submit
{{/if}}
{{/async-action-container}}
```
Then
```js
this.set('myPromise', null);
```
to reset.
The CSS classes exposed are `default`, `pending`, `settled`, `rejected`, and `fulfilled`.
Contributing
------------------------------------------------------------------------------
### Installation
* `git clone `
* `cd ember-async-action-container`
* `npm install`
### Linting
* `npm run lint:js`
* `npm run lint:js -- --fix`
### Running tests
* `ember test` – Runs the test suite on the current Ember version
* `ember test --server` – Runs the test suite in "watch mode"
* `ember try:each` – Runs the test suite against multiple Ember versions
### Running the dummy application
* `ember serve`
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).
For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
License
------------------------------------------------------------------------------
This project is licensed under the [MIT License](LICENSE.md).