ember-task-scheduler
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/ember-task-scheduler package

3.1.0 • Public • Published

ember-task-scheduler

CI NPM version Dependency Status codecov Ember Observer Score

Information

NPM

An ember-cli addon to schedule tasks to try to preserve 60 FPS rate on browsers.

Install in ember-cli application

In your application's directory:

ember install ember-task-scheduler

Usage

// Inject the service
@service scheduler;
// To schedule a callback you can use the same syntax as with Ember.run.
this.scheduler.schedule(this, 'method', arg1, arg2);

// To schedule a unique method.
this.scheduler.scheduleOnce(this, 'method', arg1, arg2);

// You can also run callbacks without context.
this.scheduler.schedule(() => {
  // Do job here.
});

// All exceptions will be throw to Ember.onerror method.

Configuration

To setup, you can set the following variables on config/environment file:

{
  "taskScheduler": {
    "FPS": 60
  }
}

If variables are unset, the will default to above configuration.

Motivation

When using requestAnimationFrame method, there are some problems when developing big applications.

Some times, requestAnimationFrame method will be executed several times on same browser frame. This will make the browser to execute all code on the next available frame. This can cause the browser to freeze due to the lack of frame scheduling.

This addon will handle this type of scheduling by running a FIFO queue with callbacks. On other words, when you run schedule method twice on same frame. This addon will try to execute the first callback on the next available frame and, if the frame can fit the next callback (execution under 60 FPS rate), will try run it. Otherwise, it will be executed on the next available frame.

Contribute

If you want to contribute to this addon, please read the CONTRIBUTING.md.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Readme

Keywords

Package Sidebar

Install

npm i ember-task-scheduler

Weekly Downloads

122

Version

3.1.0

License

MIT

Unpacked Size

25.5 kB

Total Files

16

Last publish

Collaborators

  • josex2r
  • bbvaengineer