An ember-cli addon to schedule tasks to try to preserve 60 FPS rate on browsers.
In your application's directory:
ember install ember-task-scheduler
// 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.
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.
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.
If you want to contribute to this addon, please read the CONTRIBUTING.md.
We use SemVer for versioning. For the versions available, see the tags on this repository.
See the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details.