3.1.0 • Published 2 years ago

ember-task-scheduler v3.1.0

Weekly downloads
1,059
License
MIT
Repository
github
Last release
2 years ago

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.

3.1.0

2 years ago

3.0.1

2 years ago

3.0.0

3 years ago

2.3.0

3 years ago

2.2.0

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.0

5 years ago

1.0.5

5 years ago

1.0.4

6 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.0

7 years ago