replace createStartupPluginAndRegister

This commit is contained in:
InsanusMokrassar 2022-12-15 14:59:07 +06:00
parent 5af91981f1
commit 85e5cee154

View File

@ -1,14 +1,14 @@
package dev.inmo.micro_utils.startup.launcher package dev.inmo.micro_utils.startup.plugin
import dev.inmo.micro_utils.startup.plugin.StartPlugin
import dev.inmo.micro_utils.startup.plugin.StartPluginSerializer
/** /**
* Creates [T] using [block], register it in [StartPluginSerializer] using its [StartPluginSerializer.registerPlugin] * Creates [T] using [block], register it in [StartPluginSerializer] using its [StartPluginSerializer.registerPlugin]
* and returns created by [block] plugin * and returns created by [block] plugin
*
* @param name Will be used as a key for registration in [StartPluginSerializer] and will be passed to the [block] as
* parameter
*/ */
inline fun <T : StartPlugin> createStartupPluginAndRegister(name: String, block: () -> T): T { inline fun <T : StartPlugin> createStartupPluginAndRegister(name: String, block: (String) -> T): T {
val plugin = block() val plugin = block(name)
StartPluginSerializer.registerPlugin(name, plugin) StartPluginSerializer.registerPlugin(name, plugin)
return plugin return plugin
} }