factory-function-composition

Compose clients and services using factory functions with a two-argument signature.

4.7k|374|Updated Mar 16, 2023
One-click install
npx skills add https://github.com/EpicenterHQ/epicenter --skill factory-function-composition
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: factory-function-composition
Source: https://github.com/EpicenterHQ/epicenter/tree/main/.agents/skills/factory-function-composition
Command: npx skills add https://github.com/EpicenterHQ/epicenter --skill factory-function-composition

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This pattern helps developers enforce clear separation of concerns by injecting dependencies via factory functions, reducing hidden dependencies and improving testability.

Core Features & Use Cases

  • Enables creation of services with injected clients and resources
  • Supports multi-dependency factories and explicit option layering
  • Improves testability by enabling mocks and isolation
  • Use Case: When wiring together a client, a service, and its method options in a stable, predictable way

Quick Start

Create a service by wiring dependencies with a factory and call a method to exercise the resulting service.

Frequently Asked Questions about factory-function-composition

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use factory functions for dependency injection in TypeScript?

Factory functions handle dependency injection by composing clients and services, enforcing a universal two-argument signature with resources first and configuration second to improve testability.

What is the best way to structure service composition for multiple layered dependencies?

Service composition for multiple layered dependencies is structured using multi-dependency factories and explicit option layering, keeping client creation independent of business logic.

Why does dependency injection improve testability in codebases with hidden dependencies?

Dependency injection improves testability by enabling mocks and isolation, reducing hidden dependencies so services can be created with injected clients and resources in a predictable way.

How do I mock services when wiring together a client and its method options?

Mocking services is done by using factory functions to wire clients and method options, allowing dependencies to be injected independently and easily mocked for testing.

Can I pass multiple dependencies and configuration options into a single factory function?

Yes, factory functions support multiple dependencies and explicit option layering through a universal two-argument signature, taking resources as the first argument and configuration as the second.