Type Alias: Middleware
Middleware = (
key,next,context) =>unknown
Defined in: src/types.ts:310
Wraps resolution. Call next() to continue (or next(otherKey) to resolve another key) and return the value. Returning without calling next replaces the resolution.
Parameters
key
next
(key?) => unknown
context
Returns
unknown
Example
ts
const timing: Middleware = (key, next, { depth }) => {
const start = performance.now();
const value = next();
console.debug(`${' '.repeat(depth)}${String(key)} ${performance.now() - start}ms`);
return value;
};
container.use(timing);