You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

async-container

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-container

A utility component to react to promise state changes in the DOM.


Version published
Weekly downloads
1
Maintainers
1
Created
Weekly downloads
 

Readme

Source

async-container

Build Status npm Version Ember badge

This addon enables a declarative way to react to actions which return a promise. When dealing with actions, it's common to represent the UI state while an async action is resolving. For example, a save button that needs to be disabled while a save request is in flight.

Example Usage

Conditionally disable while promise is resolving

{{!-- templates/example.hbs --}}
{{#action-container (action 'save') as |async|}}
  <button {{action async.invoke}} disabled={{async.inFlight}}>
    {{#if async.inFlight}}
      Saving
    {{else}}
      Save
    {{/if}}
  </button>
{{/action-container}}

Display the results of the promise

The result of the last successful promise result is available on async.result

{{!-- templates/example.hbs --}}
{{#action-container (action 'save') as |async|}}
  {{#if async.result}}
    Thank you {{async.result.username}}
  {{else}}
    <button {{action async.invoke}} disabled={{async.inFlight}}>
      {{#if async.inFlight}}
        Saving
      {{else}}
        Save
      {{/if}}
    </button>
  {{/if}}
{{/action-container}}
// controllers/example.js
import Ember from 'ember';

export default Ember.Controller.extend({
  actions: {
    save() {
      return this.get('model').save();
    }
  }
});

Installation

  • ember install async-container

Running

Running Tests

  • npm test (Runs ember try:testall to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit http://www.ember-cli.com/.

Keywords

FAQs

Package last updated on 01 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc