Skip to content

feat: add NetworkMockResourceLoader fun interface#59

Merged
MaxMichel2 merged 1 commit into
mainfrom
feat/networkmock-resource-loader-interface
Jul 21, 2026
Merged

feat: add NetworkMockResourceLoader fun interface#59
MaxMichel2 merged 1 commit into
mainfrom
feat/networkmock-resource-loader-interface

Conversation

@MaxMichel2

Copy link
Copy Markdown
Collaborator

Summary

  • Introduces NetworkMockResourceLoader fun interface in devview-networkmock-core, giving DI frameworks (Koin, Hilt, etc.) a named type to bind
  • Switches devview-networkmock and devview-networkmock-ktor from implementation to api for devview-networkmock-core, so the type is transitively visible to all integrators
  • Updates MockConfigRepository, NetworkMockInitializer, and NetworkMock to use the new type throughout; existing lambda call sites continue to work via SAM conversion

Motivation

In multi-module KMP projects, Compose Resources are module-scoped. When mock files live in a different module (e.g. data) than where NetworkMock is constructed (e.g. presentation), integrators previously had to define their own bridge interface, implementation, and DI binding — 3 files. With NetworkMockResourceLoader available as a named type, that collapses to a single DI binding:

// Before (3 files across domain + data modules)
// After (1 binding in the data module):
single<NetworkMockResourceLoader> { NetworkMockResourceLoader { Res.readBytes(it) } }

Test plan

  • compileAndroidMain clean on -core and -networkmock
  • Full test suite (testAndroidHostTest) passes — 284 tasks
  • detektFull passes

🤖 Generated with Claude Code

@MaxMichel2 MaxMichel2 self-assigned this Jul 20, 2026
@MaxMichel2
MaxMichel2 requested a review from matthiaslao July 20, 2026 17:24
@MaxMichel2 MaxMichel2 added the enhancement New feature or request label Jul 20, 2026
@MaxMichel2 MaxMichel2 added this to the 0.2.0 milestone Jul 20, 2026
@MaxMichel2
MaxMichel2 force-pushed the feat/networkmock-resource-loader-interface branch from b1d4d2f to 970563d Compare July 20, 2026 18:15
Replaces the raw `suspend (String) -> ByteArray` lambda with a named
fun interface in devview-networkmock-core. Gives DI frameworks a type
to bind, eliminating boilerplate in multi-module KMP projects where mock
files live in a different module than where NetworkMock is constructed.
Both -networkmock and -ktor switch their -core dependency to api() so
the type is visible to all integrators.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@MaxMichel2
MaxMichel2 force-pushed the feat/networkmock-resource-loader-interface branch from 970563d to b1bb0f0 Compare July 21, 2026 09:22
@MaxMichel2
MaxMichel2 merged commit 45c09be into main Jul 21, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants