@arckit/pipeline
v1.0.0
Published
Type-safe middleware pipeline builder with parallel execution and React provider wrapping
Downloads
76
Maintainers
Readme
@arckit/pipeline
Type-safe middleware pipeline builder with parallel execution and React provider wrapping.
📑 Table of Contents
- 🪧 About
- 📦 Installation
- 🚀 Usage
- 📖 API
- 🤗 Contributing
- 📝 License
Framework-agnostic middleware pipeline engine. Provides the core execution model for composing middlewares sequentially or in parallel, accumulating a typed context, and wrapping React providers. Used as the foundation for framework-specific builders (page, layout, route, action).
pnpm add @arckit/pipelineRender pipeline
import { render, withFetch, withMap } from '@arckit/pipeline';
const middlewares = [
withFetch('users', async () => fetchUsers()),
withMap('count', ({ users }) => users.length)
];
const page = render(middlewares)(async ({ users, count }, props) => (
<UserList users={users} count={count} />
));Shared middlewares
import { withFetch, withMap } from '@arckit/pipeline';
// withFetch: async data fetching into context
const loadUsers = withFetch('users', async () => fetchUsers());
// withMap: synchronous value derivation
const countUsers = withMap('count', ({ users }) => users.length);| Export | Description |
|--------|-------------|
| render(middlewares) | Creates an execution function from a middleware array. Handles sequential/parallel execution and provider wrapping. |
| applyProviders(providers, content) | Wraps React content with provider components. |
| withFetch(key, fetcher) | Middleware: fetches async data into context. |
| withMap(key, mapper) | Middleware: derives a synchronous value into context. |
| Provider | Type for React provider configuration (component + props). |
| Merge<A, B> | Utility type for merging context types. |
See CONTRIBUTING.md for details.
MIT © Marc Gavanier
