Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
ember-idle-scheduler
Advanced tools
Readme
Simple promise wrap around requestIdleCallback
and a promise (priority) queue.
--
For more complex logic consider using skyrocket (https://github.com/runspired/skyrocket) and/or igniter (https://github.com/runspired/igniter)
Simply calling requestIdleCallback
from different places in the code can cause that all these callbacks are fired within one same idle frame. This can cause jank, or delay time to interactivity. Calling requestIdleCallback
within previous requestIdleCallback
ensures that the next logic is executed in next idle frame. But this is not always feasible.
Wrapping requestIdleCallback
in a promise and adding those promises in a promise queue ensures that that different idle frame is received on each call.
Simply inject a service and add a callback to the queue.
idle: inject.service(),
_setFoo() {
this.get('idle').schedule(100).then(() => {
this.set('foo', this.get('_value'));
});
}
requestIdleCallback
can be used to delay non essential logic to lower the time to interactivity. Non essential logic can be used for firing up analytics, including external scripts (that are not being used in the current route) or loading content in advance.
In this example, google analytics script is included in first idle frame and a track request is fired in next one.
getGA(){
return this.get('idle').schedule(1000).then(() => {
return $.getScript('https://www.google-analytics.com/analytics.js');
}).then(() => {
let gaTrackingId = this.get('gaTrackingId');
window.ga('create', gaTrackingId, 'auto');
});
},
googleAnalytics: computed(function(){
return this.getGA();
}),
track(cb){
if(this.get('gaTrackingId')){
return this.get('googleAnalytics').then(() => {
return this.get('idle').schedule(1000);
}).then(cb);
}
},
trackPage(page, title){
this.track(() => {
window.ga('send', {
hitType: 'pageview',
page,
title
});
});
}
git clone <repository-url>
this repositorycd ember-idle-scheduler
npm install
ember serve
npm test
(Runs ember try:each
to test your addon against multiple Ember versions)ember test
ember test --server
ember build
For more information on using ember-cli, visit https://ember-cli.com/.
FAQs
The default blueprint for ember-cli addons.
We found that ember-idle-scheduler demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).