-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #488 from player-ui/jvm-async-node-ability-to-remo…
…ve-resolved-async-node jvm and ios-async-node-ability-to-remove-resolved-async-node
- Loading branch information
Showing
9 changed files
with
659 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
jvm/core/src/main/kotlin/com/intuit/playerui/core/bridge/hooks/NodeAsyncParallelBailHook2.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.intuit.playerui.core.bridge.hooks | ||
|
||
import com.intuit.hooks.AsyncParallelBailHook | ||
import com.intuit.hooks.BailResult | ||
import com.intuit.hooks.HookContext | ||
import com.intuit.playerui.core.bridge.Node | ||
import com.intuit.playerui.core.bridge.serialization.serializers.NodeWrapperSerializer | ||
import kotlinx.coroutines.ExperimentalCoroutinesApi | ||
import kotlinx.serialization.KSerializer | ||
import kotlinx.serialization.Serializable | ||
|
||
@OptIn(ExperimentalCoroutinesApi::class) | ||
@Serializable(with = NodeAsyncParallelBailHook2.Serializer::class) | ||
public class NodeAsyncParallelBailHook2<T1, T2, R : Any?>( | ||
override val node: Node, | ||
serializer1: KSerializer<T1>, | ||
serializer2: KSerializer<T2>, | ||
) : AsyncParallelBailHook<suspend (HookContext, T1, T2) -> BailResult<R>, R>(), AsyncNodeHook<R> { | ||
|
||
init { | ||
init(serializer1, serializer2) | ||
} | ||
|
||
override suspend fun callAsync(context: HookContext, serializedArgs: Array<Any?>): R { | ||
require(serializedArgs.size == 2) { "Expected exactly two arguments, but got ${serializedArgs.size}" } | ||
val (p1, p2) = serializedArgs | ||
val result = call(10) { f, _ -> | ||
f(context, p1 as T1, p2 as T2) | ||
} as R | ||
return result | ||
} | ||
|
||
internal class Serializer<T1, T2, R : Any>( | ||
private val serializer1: KSerializer<T1>, | ||
private val serializer2: KSerializer<T2>, | ||
`_`: KSerializer<R>, | ||
) : NodeWrapperSerializer<NodeAsyncParallelBailHook2<T1, T2, R>>({ | ||
NodeAsyncParallelBailHook2(it, serializer1, serializer2) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.