钩子


¥Hooks

钩子是链的一部分,即使该链仅由一个自定义(用户提供的)钩子和始终存在的默认钩子组成。钩子函数嵌套:每个都必须始终返回一个普通对象,并且链接是由于每个函数调用 next<hookName>() 而发生的,next<hookName>() 是对后续加载程序钩子的引用。

¥Hooks are part of a chain, even if that chain consists of only one custom (user-provided) hook and the default hook, which is always present. Hook functions nest: each one must always return a plain object, and chaining happens as a result of each function calling next<hookName>(), which is a reference to the subsequent loader’s hook.

返回缺少必需属性的值的钩子会触发异常。没有调用 next<hookName>() 和没有返回 shortCircuit: true 就返回的钩子也会触发异常。这些错误有助于防止链中的意外中断。

¥A hook that returns a value lacking a required property triggers an exception. A hook that returns without calling next<hookName>() and without returning shortCircuit: true also triggers an exception. These errors are to help prevent unintentional breaks in the chain.