NetworkMock

NetworkMock module for network request/response mocking during development and testing.

Implements RequiresDataStore so that com.worldline.devview.core.rememberModules automatically initialises the shared NetworkMockDataStoreDelegate before initModule is called.

The dataStoreDelegate points to NetworkMockDataStoreDelegate, the process-level singleton declared in devview-networkmock-core. This ensures that both this UI module and devview-networkmock-ktor share exactly one DataStore instance without depending on each other.

initModule passes the initialised DataStore explicitly to NetworkMockInitializer.initialize, which constructs MockStateRepository and MockConfigRepository once for the lifetime of the process.

A separate module-owned session serializes accepted UI writes and retains pending recovery through overlay hiding and host configuration changes. Deliberate registration removal ends that session. Filtering this module out of DevView returns Home and discards its entry drafts, but does not end the session while its registration remains composed.

Usage

val modules = rememberModules {
module(NetworkMock(
resourceLoader = NetworkMockResourceLoader { path -> Res.readBytes(path) },
specPaths = listOf("files/networkmocks/specs/my-backend.json")
))
}

The Ktor plugin requires no configuration when NetworkMock is registered:

val client = HttpClient(OkHttp) {
install(NetworkMockPlugin)
}

Constructors

Link copied to clipboard
constructor(resourceLoader: NetworkMockResourceLoader, specPaths: List<String>)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Points to NetworkMockDataStoreDelegate, the process-level singleton in devview-networkmock-core. Both this module and devview-networkmock-ktor reference the same delegate, guaranteeing a single DataStore instance.

Link copied to clipboard
open override val dataStoreName: String
Link copied to clipboard
open override val destinations: PersistentMap<KClass<out NavKey>, DestinationMetadata>
Link copied to clipboard
open override val entryDestination: NavKey
Link copied to clipboard
open val icon: ImageVector
Link copied to clipboard
open override val moduleName: String

Name displayed on the home screen and default destination toolbar.

Link copied to clipboard
open override val registerSerializers: PolymorphicModuleBuilder<NavKey>.() -> Unit
Link copied to clipboard
open override val section: Section
Link copied to clipboard
open override val subtitle: String

Summary displayed on the home screen.

Functions

Link copied to clipboard
Link copied to clipboard
open override fun initModule()

Initialises the network mock repositories once the DataStore is ready.

Link copied to clipboard
open override fun EntryProviderScope<NavKey>.registerContent(onNavigateBack: () -> Unit, onNavigate: (NavKey) -> Unit, bottomPadding: Dp)