Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize on a way to pass go/no-go flags to hooks #309

Closed
eddyystop opened this issue Dec 7, 2017 · 1 comment
Closed

Standardize on a way to pass go/no-go flags to hooks #309

eddyystop opened this issue Dec 7, 2017 · 1 comment

Comments

@eddyystop
Copy link
Collaborator

+## Cancelling hook chain
+
+If you want certain hooks to be skipped you may set any custom property onto context, then wrap hooks you want to skip
+into iff-hook and check.
+> Note: The aforementioned trick doesn't prevent database call. In this case context.result should be set in before hook.
+
+```js
+const { iff } = require('feathers-hooks-common');
+
+app.service('servicename').hooks({

  • before: [
  • context => {
  •  context.cancelled = true;
    
  •  return context;
    
  • },
  • iff(
  •  context => context.cancelled,
    
  •  [hookA, hookB] // <- skipped
    
  • ),
  • hookC // not skipped
  • ]
    +})
    +```
@eddyystop
Copy link
Collaborator Author

Feathers hooks now implements SKIP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant