0.1.0 • Published 5 years ago

ember-concurrency-typescript v0.1.0

Weekly downloads
61
License
MIT
Repository
github
Last release
5 years ago

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.