mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-18 14:47:15 +00:00
replace createStartupPluginAndRegister
This commit is contained in:
parent
5af91981f1
commit
85e5cee154
@ -1,14 +1,14 @@
|
||||
package dev.inmo.micro_utils.startup.launcher
|
||||
|
||||
import dev.inmo.micro_utils.startup.plugin.StartPlugin
|
||||
import dev.inmo.micro_utils.startup.plugin.StartPluginSerializer
|
||||
package dev.inmo.micro_utils.startup.plugin
|
||||
|
||||
/**
|
||||
* Creates [T] using [block], register it in [StartPluginSerializer] using its [StartPluginSerializer.registerPlugin]
|
||||
* 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 {
|
||||
val plugin = block()
|
||||
inline fun <T : StartPlugin> createStartupPluginAndRegister(name: String, block: (String) -> T): T {
|
||||
val plugin = block(name)
|
||||
StartPluginSerializer.registerPlugin(name, plugin)
|
||||
return plugin
|
||||
}
|
Loading…
Reference in New Issue
Block a user