Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace WorkflowHost with the launchWorkflowIn function. #447

Merged
merged 2 commits into from
Jul 9, 2019

Conversation

zach-klippenstein
Copy link
Collaborator

@zach-klippenstein zach-klippenstein commented Jul 7, 2019

First commit just does some refactoring to make the next commit diff cleaner.

The new API is a single function:

fun <InputT, OutputT : Any, RenderingT, ResultT> launchWorkflowIn(
  scope: CoroutineScope,
  workflow: Workflow<InputT, OutputT, RenderingT>,
  inputs: Flow<InputT>,
  initialSnapshot: Snapshot? = null,
  beforeStart: CoroutineScope.(
    renderingsAndSnapshots: Flow<RenderingAndSnapshot<RenderingT>>,
    outputs: Flow<OutputT>
  ) -> ResultT
): ResultT

See the kdoc on that function for details.

Closes #439.

@zach-klippenstein zach-klippenstein force-pushed the zachklipp/runworkflow branch 3 times, most recently from cae54fc to 9625cf3 Compare July 7, 2019 18:32
@zach-klippenstein zach-klippenstein added the enhancement New feature or request label Jul 8, 2019
@zach-klippenstein zach-klippenstein added this to the kotlin v0.18.0 milestone Jul 8, 2019
@zach-klippenstein zach-klippenstein changed the title Zachklipp/runworkflow [WIP] Zachklipp/runworkflow Jul 8, 2019
@zach-klippenstein zach-klippenstein changed the title [WIP] Zachklipp/runworkflow Replace WorkflowHost with the runWorkflow function. Jul 8, 2019
@zach-klippenstein zach-klippenstein requested a review from rjrjr July 8, 2019 23:05
@zach-klippenstein zach-klippenstein marked this pull request as ready for review July 8, 2019 23:05
@zach-klippenstein zach-klippenstein changed the title Replace WorkflowHost with the runWorkflow function. Replace WorkflowHost with the launchWorkflowIn function. Jul 8, 2019
@zach-klippenstein zach-klippenstein force-pushed the zachklipp/runworkflow branch 3 times, most recently from 950136c to ec7ae2a Compare July 9, 2019 00:23
@zach-klippenstein zach-klippenstein force-pushed the zachklipp/runworkflow branch 2 times, most recently from 44ae211 to f90206c Compare July 9, 2019 00:52
Copy link
Contributor

@rjrjr rjrjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some doc suggestions, mainly aimed at over-explaining behavior of [beforeStart] a bit more. I also think RunnerT would be a better name than ResultT.

I'm pretty thrilled with this change.

@zach-klippenstein
Copy link
Collaborator Author

@rjrjr Just pushed to address your comments, PTAL.

Copy link
Contributor

@rjrjr rjrjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could iterate on the word-smithing forever. :shipit:

* the root workflow's [StatefulWorkflow.initialState], and subsequent emissions are passed as
* input updates to the root workflow.
* @param initialSnapshot If not null, used to restore the workflow.
* @param beforeStart Called exactly once with the flows for renderings/snapshots and outputs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still find "It also gets a sub-scope" confusing since the scope is this, not a parameter. That's what got me talking about receiver elsewhere, although I take your point that that's a weird term too -- this ain't Smalltalk. Called on doesn't work for you?

@zach-klippenstein zach-klippenstein merged commit ab47bea into master Jul 9, 2019
@zach-klippenstein zach-klippenstein deleted the zachklipp/runworkflow branch July 9, 2019 21:15
@zach-klippenstein zach-klippenstein added the kotlin Affects the Kotlin library. label Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request kotlin Affects the Kotlin library.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace WorkflowHost with a static runWorkflow function
2 participants