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

[feature idea]: sequential every and some hooks #570

Open
ghsamm opened this issue Feb 3, 2020 · 0 comments
Open

[feature idea]: sequential every and some hooks #570

ghsamm opened this issue Feb 3, 2020 · 0 comments

Comments

@ghsamm
Copy link

ghsamm commented Feb 3, 2020

Hello guys,

I'm submitting the basic idea here and once you approve it, I'll add the PR with types and tests et al.

The current every and some hooks run the input hooks in parallel, but the problem with that approach is that we can't take advantage of short-circuiting.

For example, if we want to make sure the user is:

  1. is authenticated
  2. AND has access to the resource

Using the existing every hook, both checks will run for every request.

But if we had a everySeq hook for example, if the user is not authenticated, we can run the first check only and directly return an error.

Of course, for a small example like this, it wouldn't make much difference. But sometimes, one of the checks could be resource-intensive and we'd would want to live it till the end to avoid running for most requests.

What do you think ?

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

No branches or pull requests

1 participant