mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-17 22:03:50 +00:00
replace createStartupPluginAndRegister
This commit is contained in:
parent
5af91981f1
commit
85e5cee154
@ -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
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user