Skip to content

Commit

Permalink
Apply changes from ktLintFormat
Browse files Browse the repository at this point in the history
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
RBusarow authored and github-actions[bot] committed Sep 24, 2024
1 parent 4cb3633 commit ad8a4f9
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public interface BaseRenderContext<out PropsT, StateT, in OutputT> {
public fun <E1, E2, E3, E4, E5, E6, E7, E8, E9> eventHandler(
name: () -> String = { "eventHandler" },
update: WorkflowAction<@UnsafeVariance PropsT, StateT, @UnsafeVariance OutputT>
.Updater.(E1, E2, E3, E4, E5, E6, E7, E8, E9) -> Unit
.Updater.(E1, E2, E3, E4, E5, E6, E7, E8, E9) -> Unit
): (E1, E2, E3, E4, E5, E6, E7, E8, E9) -> Unit {
return { e1, e2, e3, e4, e5, e6, e7, e8, e9 ->
actionSink.send(action(name) { update(e1, e2, e3, e4, e5, e6, e7, e8, e9) })
Expand All @@ -274,7 +274,7 @@ public interface BaseRenderContext<out PropsT, StateT, in OutputT> {
public fun <E1, E2, E3, E4, E5, E6, E7, E8, E9, E10> eventHandler(
name: () -> String = { "eventHandler" },
update: WorkflowAction<@UnsafeVariance PropsT, StateT, @UnsafeVariance OutputT>
.Updater.(E1, E2, E3, E4, E5, E6, E7, E8, E9, E10) -> Unit
.Updater.(E1, E2, E3, E4, E5, E6, E7, E8, E9, E10) -> Unit
): (E1, E2, E3, E4, E5, E6, E7, E8, E9, E10) -> Unit {
return { e1, e2, e3, e4, e5, e6, e7, e8, e9, e10 ->
actionSink.send(action(name) { update(e1, e2, e3, e4, e5, e6, e7, e8, e9, e10) })
Expand All @@ -287,30 +287,30 @@ public interface BaseRenderContext<out PropsT, StateT, in OutputT> {
*/
public fun <PropsT, StateT, OutputT, ChildOutputT, ChildRenderingT>
BaseRenderContext<PropsT, StateT, OutputT>.renderChild(
child: Workflow<Unit, ChildOutputT, ChildRenderingT>,
key: String = "",
handler: (ChildOutputT) -> WorkflowAction<PropsT, StateT, OutputT>
): ChildRenderingT = renderChild(child, Unit, key, handler)
child: Workflow<Unit, ChildOutputT, ChildRenderingT>,
key: String = "",
handler: (ChildOutputT) -> WorkflowAction<PropsT, StateT, OutputT>
): ChildRenderingT = renderChild(child, Unit, key, handler)

/**
* Convenience alias of [BaseRenderContext.renderChild] for workflows that don't emit output.
*/
public fun <PropsT, ChildPropsT, StateT, OutputT, ChildRenderingT>
BaseRenderContext<PropsT, StateT, OutputT>.renderChild(
child: Workflow<ChildPropsT, Nothing, ChildRenderingT>,
props: ChildPropsT,
key: String = ""
): ChildRenderingT = renderChild(child, props, key) { noAction() }
child: Workflow<ChildPropsT, Nothing, ChildRenderingT>,
props: ChildPropsT,
key: String = ""
): ChildRenderingT = renderChild(child, props, key) { noAction() }

/**
* Convenience alias of [BaseRenderContext.renderChild] for children that don't take props or emit
* output.
*/
public fun <PropsT, StateT, OutputT, ChildRenderingT>
BaseRenderContext<PropsT, StateT, OutputT>.renderChild(
child: Workflow<Unit, Nothing, ChildRenderingT>,
key: String = ""
): ChildRenderingT = renderChild(child, Unit, key) { noAction() }
child: Workflow<Unit, Nothing, ChildRenderingT>,
key: String = ""
): ChildRenderingT = renderChild(child, Unit, key) { noAction() }

/**
* Ensures a [LifecycleWorker] is running. Since [worker] can't emit anything,
Expand All @@ -323,9 +323,9 @@ public fun <PropsT, StateT, OutputT, ChildRenderingT>
*/
public inline fun <reified W : LifecycleWorker, PropsT, StateT, OutputT>
BaseRenderContext<PropsT, StateT, OutputT>.runningWorker(
worker: W,
key: String = ""
) {
worker: W,
key: String = ""
) {
runningWorker(worker, key) {
// The compiler thinks this code is unreachable, and it is correct. But we have to pass a lambda
// here so we might as well check at runtime as well.
Expand All @@ -348,9 +348,9 @@ public inline fun <reified W : LifecycleWorker, PropsT, StateT, OutputT>
)
public inline fun <reified W : Worker<Nothing>, PropsT, StateT, OutputT>
BaseRenderContext<PropsT, StateT, OutputT>.runningWorker(
worker: W,
key: String = ""
) {
worker: W,
key: String = ""
) {
runningWorker(worker, key) {
// The compiler thinks this code is unreachable, and it is correct. But we have to pass a lambda
// here so we might as well check at runtime as well.
Expand Down Expand Up @@ -378,10 +378,10 @@ public inline fun <reified W : Worker<Nothing>, PropsT, StateT, OutputT>
*/
public inline fun <T, reified W : Worker<T>, PropsT, StateT, OutputT>
BaseRenderContext<PropsT, StateT, OutputT>.runningWorker(
worker: W,
key: String = "",
noinline handler: (T) -> WorkflowAction<PropsT, StateT, OutputT>
) {
worker: W,
key: String = "",
noinline handler: (T) -> WorkflowAction<PropsT, StateT, OutputT>
) {
runningWorker(worker, typeOf<W>(), key, handler)
}

Expand All @@ -396,11 +396,11 @@ public inline fun <T, reified W : Worker<T>, PropsT, StateT, OutputT>
@PublishedApi
internal fun <T, PropsT, StateT, OutputT>
BaseRenderContext<PropsT, StateT, OutputT>.runningWorker(
worker: Worker<T>,
workerType: KType,
key: String = "",
handler: (T) -> WorkflowAction<PropsT, StateT, OutputT>
) {
worker: Worker<T>,
workerType: KType,
key: String = "",
handler: (T) -> WorkflowAction<PropsT, StateT, OutputT>
) {
val workerWorkflow = WorkerWorkflow<T>(workerType, key)
renderChild(workerWorkflow, props = worker, key = key, handler = handler)
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ public abstract class StatefulWorkflow<
name: String = "safeEventHandler",
crossinline onFailedCast: (name: String, type: KClass<*>, state: StateT) -> Unit =
::defaultOnFailedCast,
crossinline update:
// Type variance issue: https://github.com/square/workflow-kotlin/issues/891
crossinline update: // Type variance issue: https://github.com/square/workflow-kotlin/issues/891
WorkflowAction<@UnsafeVariance PropsT, StateT, @UnsafeVariance OutputT>.Updater.(
currentState: CurrentStateT
) -> Unit
Expand Down Expand Up @@ -218,7 +217,13 @@ public abstract class StatefulWorkflow<
}

public inline fun <
reified CurrentStateT : StateT & Any, E1, E2, E3, E4, E5, E6
reified CurrentStateT : StateT & Any,
E1,
E2,
E3,
E4,
E5,
E6
> safeEventHandler(
name: String = "safeEventHandler",
crossinline onFailedCast: (name: String, type: KClass<*>, state: StateT) -> Unit =
Expand All @@ -242,7 +247,14 @@ public abstract class StatefulWorkflow<
}

public inline fun <
reified CurrentStateT : StateT & Any, E1, E2, E3, E4, E5, E6, E7
reified CurrentStateT : StateT & Any,
E1,
E2,
E3,
E4,
E5,
E6,
E7
> safeEventHandler(
name: String = "safeEventHandler",
crossinline onFailedCast: (name: String, type: KClass<*>, state: StateT) -> Unit =
Expand All @@ -267,7 +279,15 @@ public abstract class StatefulWorkflow<
}

public inline fun <
reified CurrentStateT : StateT & Any, E1, E2, E3, E4, E5, E6, E7, E8
reified CurrentStateT : StateT & Any,
E1,
E2,
E3,
E4,
E5,
E6,
E7,
E8
> safeEventHandler(
name: String = "safeEventHandler",
crossinline onFailedCast: (name: String, type: KClass<*>, state: StateT) -> Unit =
Expand Down Expand Up @@ -295,7 +315,16 @@ public abstract class StatefulWorkflow<
}

public inline fun <
reified CurrentStateT : StateT & Any, E1, E2, E3, E4, E5, E6, E7, E8, E9
reified CurrentStateT : StateT & Any,
E1,
E2,
E3,
E4,
E5,
E6,
E7,
E8,
E9
> safeEventHandler(
name: String = "safeEventHandler",
crossinline onFailedCast: (name: String, type: KClass<*>, state: StateT) -> Unit =
Expand Down Expand Up @@ -324,7 +353,17 @@ public abstract class StatefulWorkflow<
}

public inline fun <
reified CurrentStateT : StateT & Any, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10
reified CurrentStateT : StateT & Any,
E1,
E2,
E3,
E4,
E5,
E6,
E7,
E8,
E9,
E10
> safeEventHandler(
name: String = "safeEventHandler",
crossinline onFailedCast: (name: String, type: KClass<*>, state: StateT) -> Unit =
Expand Down Expand Up @@ -607,9 +646,9 @@ public inline fun <StateT, OutputT, RenderingT> Workflow.Companion.stateful(
*/
public fun <PropsT, StateT, OutputT, RenderingT>
StatefulWorkflow<PropsT, StateT, OutputT, RenderingT>.action(
name: String = "",
update: WorkflowAction<PropsT, StateT, OutputT>.Updater.() -> Unit
): WorkflowAction<PropsT, StateT, OutputT> = action({ name }, update)
name: String = "",
update: WorkflowAction<PropsT, StateT, OutputT>.Updater.() -> Unit
): WorkflowAction<PropsT, StateT, OutputT> = action({ name }, update)

/**
* Convenience to create a [WorkflowAction] with parameter types matching those
Expand All @@ -622,9 +661,9 @@ public fun <PropsT, StateT, OutputT, RenderingT>
*/
public fun <PropsT, StateT, OutputT, RenderingT>
StatefulWorkflow<PropsT, StateT, OutputT, RenderingT>.action(
name: () -> String,
update: WorkflowAction<PropsT, StateT, OutputT>.Updater.() -> Unit
): WorkflowAction<PropsT, StateT, OutputT> = object : WorkflowAction<PropsT, StateT, OutputT>() {
name: () -> String,
update: WorkflowAction<PropsT, StateT, OutputT>.Updater.() -> Unit
): WorkflowAction<PropsT, StateT, OutputT> = object : WorkflowAction<PropsT, StateT, OutputT>() {
override fun Updater.apply() = update.invoke(this)
override fun toString(): String = "action(${name()})-${this@action}"
}

0 comments on commit ad8a4f9

Please sign in to comment.