File tree Expand file tree Collapse file tree
thread/src/main/java/dev/mmrlx/thread/ktx Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package dev.mmrlx.thread.ktx
22
3+ import dev.mmrlx.thread.RootArgs
34import dev.mmrlx.thread.RootCallable
45import kotlinx.coroutines.flow.Flow
56
@@ -21,4 +22,18 @@ fun <T> RootCallable<T>.asFlow(): Flow<T> = rootFlow(this)
2122 *
2223 * @return The result of the [RootCallable] execution.
2324 */
24- suspend fun <T > RootCallable<T>.asThread (): T = rootThread(this )
25+ suspend fun <T > RootCallable<T>.asThread (): T = rootThread(this )
26+
27+ /* *
28+ * Invokes the [RootCallable] instance as a function.
29+ *
30+ * This operator function allows for a concise syntax to execute the callable
31+ * logic, delegating the execution to the underlying thread mechanism.
32+ *
33+ * @return The result produced by the [RootCallable].
34+ */
35+ suspend operator fun <T > RootCallable<T>.invoke (args : Map <String , Any >? = null): T {
36+ if (args == null ) return rootThread(this )
37+ val mArgs = RootArgs .of(args)
38+ return rootThread(mArgs, this )
39+ }
You can’t perform that action at this time.
0 commit comments