-
Notifications
You must be signed in to change notification settings - Fork 29
Conversation
As per discussion with @eddyystop, @marshallswain and @ekryski today. |
That sure cleaned up things nicely! |
Bump! @daffl you shipping this guy? |
Was there discussion about removing or deprecating There does not seem to be a way for the performance tool to add an const feathers = require('feathers');
const hooks = require('feathers-hooks');
const app = feathers() .configure(hooks()) .configure(services);
function services() {
this.use('/messages', {
create(data, params) {
console.log('create. throw', data.throw);
return data.throw ? Promise.reject(new Error('x')) : Promise.resolve();
},
});
const messages = this.service('messages');
messages.hooks({
before: {
all: () => { console.log('#1 before all'); },
create: () => { console.log('#1 before create'); },
},
after: {
all: () => { console.log('#1 after all'); },
create: () => { console.log('#1 after create'); },
},
error: {
all: () => { console.log('#1 error all'); },
}
});
messages.before({
all: () => { console.log('#1a before all'); },
});
}
const messages = app.service('messages');
messages.after({
before: {
all: () => { console.log('#2 before all'); },
create: () => { console.log('#2 before create'); },
},
after: {
all: () => { console.log('#2 after all'); },
create: () => { console.log('#2 after create'); },
},
error: {
all: () => { console.log('#2 error all'); },
}
});
messages.before({
all: () => { console.log('#3 before all'); },
create: () => { console.log('#3 before create'); },
});
messages.after({
all: () => { console.log('#3 after all'); },
create: () => { console.log('#3 after create'); },
});
messages.create({ throw: false });
setTimeout(() => {
console.log('=====');
messages.create({ throw: true });
}, 100); |
@eddyystop We were thinking of removing |
Your example 1 is how we were thinking it should be. However, looking at the output I would have expected:
|
I was expecting multiple service.hook() to concatenate but they don't seem I added the service.before() only to test what was going on. On Sat, Oct 22, 2016 at 12:14 PM, Eric Kryski [email protected]
|
They should and I'll make sure that they concatenate today. They shouldn't work differently at least because |
@eddyystop I created a test in #117 that verifies that hooks get chained the same way they used to and it seems to work as expected (at least v1.5 with just |
This pull request adds a
.hooks
service method that supports any kind of hook (without having to add each as a service method itself).service.before
andservice.after
are kept for backwards compatibility. They can be used and chained like all hooks already used. Basically anyservice.before(anything);
becomesservice.hooks({ before: anything })
. Some examples: