question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Essentially 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:closed
  • Created 7 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
eddyystopcommented, Dec 20, 2016

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.

0reactions
eddyystopcommented, May 27, 2017

@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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found