ember-concurrency-typescript

0.1.0 • Public • Published

ember-concurrency-typescript

Build Status npm version Download Total Ember Observer Score
ember.js ember-cli ember-cli-babel
code style: prettier dependencies devDependencies

Use ember-concurrency fully type-checked with ember-cli-typescript & native class syntax.

Installation

ember install ember-concurrency-typescript

If you haven't already, you also need to install ember-concurrency and ember-cli-typescript:

ember install ember-concurrency ember-cli-typescript

Usage

import { task, taskGroup, timeout } from 'ember-concurrency';
 
class Foo {
  slowGreeting = task(function*(this: Foo, delay: number, name: string) {
    yield timeout(delay);
    return `Hello, ${name}!`;
  });
 
  someRestartableTask = task(function*(this: Foo) {
    // ...
  }).restartable();
 
  someTaskGroup = taskGroup()
    .enqueue()
    .maxConcurrency(1);
 
  someGroupTask = task(function*(this: Foo) {
    // ...
  }).group('someTaskGroup');
 
  anotherGroupTask = task(function*(this: Foo) {
    // ...
  }).group('someTaskGroup');
 
  async greetTomDale() {
    // Parameters and return type are inferred correctly!
    const greeting = await this.slowGreeting.perform(1000, 'Tom Dale');
    console.log(greeting);
  }
}

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

Package Sidebar

Install

npm i ember-concurrency-typescript

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

19.9 kB

Total Files

13

Last publish

Collaborators

  • buschtoens