getModule

abstract fun <M : Any> getModule(moduleClass: KClass<M>): M?(source)

Get a module instance by its class.

Use this when the module type is only known at runtime (e.g. dynamic plugin systems, middleware, debug tooling). When the type is known at compile time, prefer the reified overload getModule or getRegisteredModules for Swift/Obj-C interop.

Example usage:

val navModule = storeAccessor.getModule(NavigationModule::class)
?: error("NavigationModule not registered")

Return

The module instance if registered, null otherwise

Parameters

moduleClass

The KClass of the module to retrieve

See also

reified overload for compile-time known types

for Swift/Obj-C interop


inline fun <M : Any> getModule(): M?(source)

Convenience reified overload for getModule.

Preferred way to retrieve a module from Kotlin when the type is known at compile time.

Example usage:

val navModule = storeAccessor.getModule<NavigationModule>()
?: error("NavigationModule not registered")

Return

The module instance if registered, null otherwise

See also

for Swift/Obj-C interop