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)
}Properties
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.
Name displayed on the home screen and default destination toolbar.
Functions
Initialises the network mock repositories once the DataStore is ready.