Add defer Hook
See original GitHub issueEssentially it would take a hook function, and run it outside of the rest of the hooks - so that if an error occurs, it doesn’t break the request, or if it will potentially take a long time it won’t cause lags. Where I’ve used something like this is for analytics or low priority notifications.
Obviously you could just bake the functionality directly into the hook, but if you’re consuming 3rd party hooks, or have a hook you sometimes want to depend on, that wouldn’t work.
Is this common enough to be bundled into hooks-common
/ is there a pattern like this already for feathers?
I’m thinking something like this:
function defer(handler) {
return function(hook) {
setImmediate(() => handler.call(this, hook));
return hook;
}
}
app.service('users').after({
create: [ defer(notify('User Created')) ]
});
Happy to make a PR
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
How to Defer Parsing of JavaScript in WordPress (4 Methods)
There are a few different ways to defer parsing of JavaScript. First, there are two attributes that you can add to your scripts: ......
Read more >How to Defer Parsing of JavaScript in WordPress - Hostinger
Go to your WordPress Dashboard. · On the left sidebar, navigate to Speed Booster. · Click the Advanced tab, and activate Defer parsing...
Read more >How to add defer="defer" tag in plugin javascripts?
As of WordPress 4.1 there is a filter: script_loader_tag . You can use it to find the correct script: add_filter( 'script_loader_tag' ...
Read more >Add Defer and Async to WordPress Enqueued Scripts - WP-Mix
This function first checks the JavaScript handle. If it is for our plugin, then two things happen. First the tag is checked for...
Read more >How to Defer Parsing of Enqueued JavaScript Files in ...
The key is to get the handle for each of the enqueued files and add it to the $defer array. In the wp_enqueue_scripts...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for this comment.
Work is being done on hooks for event filters and permissions. We’ll address this particular issue when that’s stabilized.
@bedeoverend I took the liberty of adding your (modified) defer hook as the first addition to the new
feathers-community-hooks
repo. I renamed it to runParallel. Feel free to modify it based on your experience.I’d be delighted if you were able to contribute more hooks.
Thanks!