The function or object to wrap with middleware
One or more middleware to apply, executed in priority order
A new invokable function that applies the middleware chain
function main(use: Use): void {
// Apply a single middleware
const logged = use(fetchData, loggingMiddleware);
// Apply multiple middlewares (executed in priority order)
const enhanced = use(fetchData, [
{ priority: 0, invoke: authMiddleware },
{ priority: 10, invoke: cacheMiddleware },
{ priority: 20, invoke: loggingMiddleware }
]);
// Call the wrapped function
const result = logged(arg1, arg2);
}
UseFactorySettingsMiddlewareInvokableIMPORT_PATH: @daiso-tech/core/middleware
Function that applies a middleware chain to an invokable function or object.
Wraps the provided invokable with the specified middlewares, creating a new function that executes all middlewares in priority order before delegating to the original invokable.