-
-
Notifications
You must be signed in to change notification settings - Fork 752
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
Make feathers-hooks part of core and service events a hook #408
Comments
👍 and also agree that server-event-emitting can be treated as a kind of hooks. Actually I found hooks and server-event-filters are quite similar: hooks get something done under some situations; filters get something(event broadcasting) not done under some situations. Before the filters become hooks, I would like to suggest adding 'feather generate filter' to the cli tool, since I find myself always writing the same filter structuring code (just like |
Filters (with some sane defaults) are definitely going to be added in the next version of the CLI. I don't think we'll add any built in hooks to core, instead it probably makes most sense to consolidate them all in https://github.com/feathersjs/feathers-hooks-common (unless they are specific to the plugin, e.g. for feathers-authentication). |
This sounds like a fantastic idea, treating service events as hooks. I have a use case where I only want to send changed properties over the wire for |
@petermikitsh I have the exact use case. Were you able to figure out a solution for this with the current system? |
You can already create a hook that does a diff with the previous data like this: app.service('myservice').hooks({
before: {
patch(hook) {
return hook.service.get(hook.id).then(previous => {
hook.previousData = previous;
return hook;
});
}
},
after: {
patch(hook) {
hook.result = diff(hook.result, hook.previousData);
}
}
}); |
I've been happy with npm |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs. |
The feathers-hooks plugin has become such an essential part of Feathers that it should probably become a core dependency. A good time to implement this is when removing callback support in both, hooks and services in Feathers v3.
This would also allow us to improve the service event dispatching by turning it into a hook (that always runs last) instead of a separate mixin (where the same functionality is currently provided by a different dependency Rubberduck).
Related issues:
hook.app
is undefined in Event filters #405 and Create an app reference on service event hook object #406 are related to this but not completely solve the problem because thehook
object in a service event is not the same as during the method call (which it should be).The text was updated successfully, but these errors were encountered: