-
Notifications
You must be signed in to change notification settings - Fork 399
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
problem about tap method of interceptor #78
Comments
It seems like hook.intercept({
register:(tapInfo) => {
console.log(tapInfo)
}
}) Based on the documentation, I would have expected |
I looked through the code. When a hook is triggered, For example: const { SyncHook } = require("tapable");
const greetingHook = new SyncHook(["name"]);
greetingHook.intercept({
register: (tapInfo) => {
console.log("👾 new tap was registered", tapInfo);
},
call: (name) => {
console.log("🙄 tapped method was called", name);
},
tap: (tapInfo) => {
console.log("🙊 tapped method was called", tapInfo);
}
});
greetingHook.tap("EmailPlugin", function (name) {
console.log("Hi, this is an email for " + name);
});
// 👾 new tap was registered { type: "sync", fn: [Function], name: "EmailPlugin" }
greetingHook("Anthony");
// 🙄 tapped method was called Anthony
// 🙊 tapped method was called { type: "sync", fn: [Function], name: "EmailPlugin" } @ooflorent Is this correct? If so, I could update the docs to make this more clear. |
thanks for your reply,from the implementation of tapable, what u described is true. And what makes me confused are the docs.
these code will generate the function as follow.
from the generatored anonymous function, we can see that
Last but not least, i really really want the official team can improve the quality of this doc 🙏 🙏 🙏. I am willing to make some efforts to improve the doc. |
first thanks for your reply, i am agree with what you described above.
from the anonymous generated above, we can see that the
so when developer trigger the In summary, what you described is right absolutely. Last but not least, i really really want the official team can improve the quality of the doc, and i'm willing to contribute the doc if any need. |
recently i try to use interceptor of tapable, in the Interception section of readme:
it means if i use a intecptor of tap method, when a plugin taps into a hook, the corresponding function will be invoked. However, the following code snippet does not work as expected.
code snippet:
tap of interceptor only be called when it execute
hook.call('webpack')
.version of tapable: 1.1.0
The text was updated successfully, but these errors were encountered: