Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.squareup.workflow1

import com.squareup.workflow1.WorkflowInterceptor.RenderContextInterceptor
import com.squareup.workflow1.WorkflowInterceptor.RuntimeUpdate
import com.squareup.workflow1.WorkflowInterceptor.WorkflowSession
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
Expand Down Expand Up @@ -194,6 +195,8 @@ public interface WorkflowInterceptor {
/**
* Information about the session of a workflow in the runtime that a [WorkflowInterceptor] method
* is intercepting.
*
* Implementations should override [toString] to call [WorkflowSession.workflowSessionToString].
*/
public interface WorkflowSession {
/** The [WorkflowIdentifier] that represents the type of this workflow. */
Expand Down Expand Up @@ -419,6 +422,16 @@ internal fun <P, S, O, R> WorkflowInterceptor.intercept(
}
}

internal fun WorkflowSession.workflowSessionToString(): String {
val parentDescription = parent?.let { "WorkflowInstance(…)" }
return "WorkflowInstance(" +
"identifier=$identifier, " +
"renderKey=$renderKey, " +
"instanceId=$sessionId, " +
"parent=$parentDescription" +
")"
}

private class InterceptedRenderContext<P, S, O>(
private val baseRenderContext: BaseRenderContext<P, S, O>,
private val interceptor: RenderContextInterceptor<P, S, O>
Expand Down
Loading
Loading