Skip to content

Commit a3cd320

Browse files
committed
Make it possible to pass a provider to tasks() and batchItems()
1 parent ed70065 commit a3cd320

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/main/kotlin/myaa/subkt/tasks/plugin.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,20 @@ open class Subs(val project: Project) : ItemGroupContext() {
393393
/**
394394
* Creates a context for generating tasks for the specified entries.
395395
*
396+
* @param entries A list of entries to generate tasks for.
396397
* @param action A closure operating on a [ItemGroupContext] entry.
397398
*/
398-
fun tasks(episodes: Iterable<String>, action: ItemGroupContext.() -> Unit) =
399-
InnerContext(episodes).action()
399+
fun tasks(entries: Iterable<String>, action: ItemGroupContext.() -> Unit) =
400+
InnerContext(entries).action()
401+
402+
/**
403+
* Creates a context for generating tasks for the specified entries.
404+
*
405+
* @param entries A provider for a list of entries to generate tasks for.
406+
* @param action A closure operating on a [ItemGroupContext] entry.
407+
*/
408+
fun tasks(entries: Provider<out Iterable<String>>, action: ItemGroupContext.() -> Unit) =
409+
InnerContext(entries).action()
400410

401411
private val engine = VelocityEngine().also {
402412
val p = Properties()

src/main/kotlin/myaa/subkt/tasks/tasks.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,20 @@ abstract class ItemGroup<T>(
274274
/**
275275
* Get all items corresponding to the specified entries.
276276
*
277+
* @param entries A list of entries to get the items for.
277278
* @sample myaa.subkt.tasks.samples.itemGroupItemsSample1
278279
*/
279280
fun batchItems(entries: Iterable<String>) = entries.map { items.getValue(it) }
280281

282+
/**
283+
* Get all items corresponding to the specified entries.
284+
*
285+
* @param entries A provider for a list of entries to get the items for.
286+
* @sample myaa.subkt.tasks.samples.itemGroupItemsSample1
287+
*/
288+
fun batchItems(entries: Provider<out Iterable<String>>) =
289+
entries.get().map { items.getValue(it) }
290+
281291
/**
282292
* Get all items corresponding to the episodes of the given task.
283293
*

0 commit comments

Comments
 (0)