NetworkMock

class NetworkMock(resourceLoader: suspend (String) -> ByteArray, configPath: String = "files/networkmocks/mocks.json") : Module, RequiresDataStore

NetworkMock module — manages network request/response mocking for 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.

Usage

val modules = rememberModules {
module(NetworkMock(
resourceLoader = { path -> Res.readBytes(path) }
))
}

The Ktor plugin requires no configuration when NetworkMock is registered:

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

Constructors

Link copied to clipboard
constructor(resourceLoader: suspend (String) -> ByteArray, configPath: String = "files/networkmocks/mocks.json")

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 val moduleName: String
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 val subtitle: String?

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)