-
Notifications
You must be signed in to change notification settings - Fork 89
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
alterItems now works with an async callback function #371
alterItems now works with an async callback function #371
Conversation
Thanks for the PR! There's a bit more to do. Feathers is supported on NodeJS v6 and v8. v6 does not support Its preferable the tests also do not use |
Ah okay. I will implement the changes asap :) |
Hey, I updated the code and the tests and removed every async / await |
Thank you. |
In v4.12.0. Docs updated. |
This breaks my workflow with synchronous alterItems, they all turn into promises, it's a breaking change. I think if there is no asynchronous then we should not return a promise. EDIT: Or write on the doc that this hook now returns a promise in any case ? |
Hmm, I think it would be cleaner to change the docs. Because different return values based on the callback might be confusing:
@eddyystop What do you think? PS: How do you use alterItems? If you use it as normal hook it should simply work. Do you call it yourself in a custom hook? |
The hook may be called with a Promise as a param with the caller rightly expecting the hook to return a Promise. That Promise param can be resolved by the time the hook processes it. So I don't think we can use the existance of a Promise param to determine if a Promise result is returned or not. Is there something else we can do other than having separate signatures/hooks for sync and async params? This issue is pretty important as alterItems is likely used sync more often than async. |
@eddyystop Don't get what you're trying to say 😄 Be careful. I hacked it together. It does not use the hook context and therefore does not work with feathers. I just ran it in a quokka env to test it and therefore simplified the in- & output. It now behaves as I outlined in my other comment:
|
|
What you suggest should work. It was used at least in some old common hook code; maybe its still used. I would suggest calculating I can fix the hook Wed or Thurs, else I can look at a PR. |
@sean-nicholas, please check #409 works with your code. |
#409 works for me 👍 |
Summary
alterItems did not work with a async callback function. See #367
This PR fixes #367
Documentation at: feathers-plus/docs#19