From 736b80835f67c9c34657074ebcfbe0752bef1c18 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Thu, 17 Oct 2019 21:58:34 +0200 Subject: Move DSL builder functions out of the companion objects (#93) --- src/main/kotlin/pl/treksoft/kvision/html/Link.kt | 28 +++++++++++------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'src/main/kotlin/pl/treksoft/kvision/html/Link.kt') diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt index 63104248..2c2f1723 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt @@ -83,20 +83,18 @@ open class Link( } return this } +} - companion object { - /** - * DSL builder extension function. - * - * It takes the same parameters as the constructor of the built component. - */ - fun Container.link( - label: String, url: String? = null, icon: String? = null, image: ResString? = null, - classes: Set = setOf(), init: (Link.() -> Unit)? = null - ): Link { - val link = Link(label, url, icon, image, classes).apply { init?.invoke(this) } - this.add(link) - return link - } - } +/** + * DSL builder extension function. + * + * It takes the same parameters as the constructor of the built component. + */ +fun Container.link( + label: String, url: String? = null, icon: String? = null, image: ResString? = null, + classes: Set = setOf(), init: (Link.() -> Unit)? = null +): Link { + val link = Link(label, url, icon, image, classes).apply { init?.invoke(this) } + this.add(link) + return link } -- cgit