factory-ctx

Resolve injectable types within DynProvider::with_ctx closures using FactoryCtx.

Updated May 10, 2026
One-click install
npx skills add https://github.com/jymchng/injectable --skill factory-ctx
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: factory-ctx
Source: https://github.com/jymchng/injectable/tree/main/skills/factory-ctx
Command: npx skills add https://github.com/jymchng/injectable --skill factory-ctx

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

The Skill addresses the need for scoped resolution of injectable types within dynamic provider contexts, ensuring that dependencies are resolved in a safe and efficient manner without bypassing the singleton cache.

Core Features & Use Cases

  • Scoped Resolution: Allows for the safe resolution of injectable or external types within DynProvider::with_ctx closures.
  • Singleton Cache Utilization: Ensures that singleton dependencies are resolved within their intended scope, avoiding cache bypassing.
  • Use Case: When a dynamic provider factory needs to resolve other injectable types without affecting the singleton cache, FactoryCtx is a useful tool.

Quick Start

To utilize FactoryCtx, include the following in your Skill code:

let container = Container::builder()
    .register(DynProvider::with_ctx(|ctx| async move {
        // Resolve AppConfig via FactoryCtx
        let cfg: Inject<AppConfig> = ctx.extract().await?;
        // Further operations...
    }))
    .build().await?;

Frequently Asked Questions about factory-ctx

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

FAQPage Schema
How do I resolve injectable types inside a dynamic provider context in Rust without bypassing the singleton cache?

You resolve injectable types within dynamic provider contexts by using FactoryCtx, which ensures safe dependency management without bypassing the singleton cache during scoped resolution.

What is scope-safe dependency injection and when do I need it for dynamic provider factories?

Scope-safe dependency injection ensures dependencies resolve within their intended scope. You need it when dynamic provider factories must resolve injectable types without affecting the singleton cache.

How do I use FactoryCtx to extract dependencies within a DynProvider::with_ctx closure?

You use `ctx.extract().await` inside the `DynProvider::with_ctx` closure to resolve injectable types like AppConfig safely within the dynamic provider's scoped context.

Can I use scoped resolution for transient dependencies in Rust injection frameworks?

Yes, scoped resolution supports both singleton and transient dependencies. FactoryCtx provides scoped access to these injectable types within dynamic provider contexts in Rust injection frameworks.

Why does my dynamic provider bypass the singleton cache when resolving dependencies?

Dynamic providers bypass the singleton cache without scoped resolution. FactoryCtx prevents this by ensuring singleton dependencies resolve within their intended scope during dependency management.