Skip to content

Add Metro DI sample app (service-metro)#126

Draft
Copilot wants to merge 1 commit intomasterfrom
copilot/create-service-metro-sample
Draft

Add Metro DI sample app (service-metro)#126
Copilot wants to merge 1 commit intomasterfrom
copilot/create-service-metro-sample

Conversation

Copy link

Copilot AI commented Jan 29, 2026

New sample app demonstrating Metro dependency injection as an alternative to the existing Hilt-based service-hilt sample.

Changes

Version Catalog (gradle/libs.versions.toml)

  • Added Metro 0.10.2 plugin and runtime dependency

New Module (samples/service-metro/)

  • ServiceScope annotation for service-scoped dependencies
  • AppGraph using @DependencyGraph(AppScope::class) for app-level DI
  • ServiceGraph using @GraphExtension(ServiceScope::class) for service-level DI

Key Metro Patterns

@GraphExtension(ServiceScope::class)
@SingleIn(ServiceScope::class)
interface ServiceGraph {
    val serviceOverlay: ServiceOverlay

    @GraphExtension.Factory
    interface Factory {
        fun create(): ServiceGraph
    }
}

Graph creation in FloatingApplication:

val appGraph: AppGraph by lazy {
    createGraphFactory<AppGraph.Factory>().create(this)
}

Service obtains scoped dependencies via graph extension:

serviceGraph = FloatingApplication.instance.appGraph.serviceGraphFactory.create()

Verified with ./gradlew :samples:service-metro:assembleDebug.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • zacsweers.github.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Create metro sample app based on service-hilt Add Metro DI sample app (service-metro) Jan 29, 2026
Copilot AI requested a review from ArthurKun21 January 29, 2026 04:35
Co-authored-by: ArthurKun21 <16458204+ArthurKun21@users.noreply.github.com>
@ArthurKun21 ArthurKun21 force-pushed the copilot/create-service-metro-sample branch from 6415656 to 205efa7 Compare February 9, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants