JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16093
  • Score
    100M100P100Q149610F
  • License MIT

decorator syntax for declaring/configuring ember-concurrency tasks

Package Exports

  • ember-concurrency-decorators

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ember-concurrency-decorators) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ember-concurrency-decorators

EXPERIMENTAL

Babel support for decorator syntax has been fidgety, so expect a bit of a bumpy ride. Also, the API of this addon is still pre-Alpha. Probably don't use this in prod code.

Overview

This Ember Addon let's you use the decorator syntax for declaring/configuring ember-concurrency tasks.

Classic syntax (without decorators):

import { task } from 'ember-concurrency';
export default Ember.Component.extend({
  doStuff: task(function * () {
    // ...
  }).restartable()
});

// elsewhere:
this.get('doStuff').perform();

With decorator syntax

import { restartableTask } from 'ember-concurrency-decorators';
export default Ember.Component.extend({
  @restartableTask
  doStuff: function * () {
    // ...
  }
});

// elsewhere:
this.get('doStuff').perform();
// `doStuff` is still a Task object that can be `.perform()`ed

There's actually an even nicer syntax that's on the horizon, but is NOT YET SUPPORTED due to a Babel bug.

export default Ember.Component.extend({
  // THIS SYNTAX IS NOT YET SUPPORTED, BUT SOON!
  @restartableTask
  *doStuff() {
    // ...
  }
});

When this Babel issue is addressed, this syntax should Just Work with this addon.

Check out this weaksauce test to see all the decorators you can use.

Installation

You'll probably have an easier time setting things up by upgrading to Babel 6 and ember-cli@2.13+ first. I'm not sure how to make it work for older Babel (maybe it can't?).

Once you've done that:

ember install ember-concurrency-decorators
npm install --save babel-plugin-transform-decorators-legacy

Then you'll need to enable the decorator transpilation plugin in your ember-cli-build.js file:

  var app = new EmberApp({
    babel: {
      plugins: ['transform-decorators-legacy']
    }
  });

Working on this repo

  • git clone <repository-url> this repository
  • cd ember-concurrency-decorators
  • npm install

Running

Running Tests

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

Building

  • ember build

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