Skip to content

Commit 1eb962a

Browse files
Add ProviderDslProperty<List<T>> by T
1 parent 4964823 commit 1eb962a

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

invui-kotlin/src/main/kotlin/xyz/xenondevs/invui/dsl/ProviderDslProperty.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,28 @@ infix fun <T : Any> ProviderDslProperty<in T>.by(valueBuilder: DataComponentBuil
115115
infix fun <T : Any> ProviderDslProperty<in T>.by(valueBuilder: Provider<DataComponentBuilder<T>>): Unit =
116116
by(valueBuilder.map(DataComponentBuilder<T>::build))
117117

118+
/**
119+
* Sets this [List] property to a single value.
120+
* ```
121+
* lore by Component.text("Single line lore")
122+
* ```
123+
*/
124+
@JvmName("listByValue")
125+
@ExperimentalDslApi
126+
infix fun <T : Any> ProviderDslProperty<in List<T>>.by(value: T): Unit =
127+
by(listOf(value))
128+
129+
/**
130+
* Sets this [List] property to a provider of a single value.
131+
* ```
132+
* lore by provider(Component.text("Single line lore"))
133+
* ```
134+
*/
135+
@JvmName("listByValueProvider")
136+
@ExperimentalDslApi
137+
infix fun <T : Any> ProviderDslProperty<in List<T>>.by(value: Provider<T>): Unit =
138+
by(value.map(::listOf))
139+
118140
/**
119141
* A DSL property backed by a [Provider]. Can be set to a static value or bound to a reactive
120142
* [Provider] using the [by] infix function.

0 commit comments

Comments
 (0)