Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

wip trying to implement "person as a function" in workflow#1418

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
zach-klippenstein wants to merge11 commits intomain
base:main
Choose a base branch
Loading
fromzachklipp/coroutine-stepper

Conversation

@zach-klippenstein
Copy link
Collaborator

@zach-klippensteinzach-klippenstein commentedAug 28, 2025
edited
Loading

Inspired by the end of@swankjesse's talkCoroutines Party Tricks. Very rough sketch, missing the auto-loading screen feature, mostly just because I ran out of time. See the kdoc onBackStackWorkflow for more.

enumclassMyOutputs {Back,Done,}data classRetryScreen(valmessage:String,valonRetryClicked: ()->Unit,valonCancelClicked: ()->Unit,) : Screendata objectLoadingScreen :ScreenclassMyWorkflow(privatevalchild1:Workflow<Unit,String,Screen>,privatevalchild2:Workflow<Unit,String,Screen>,privatevalchild3:Workflow<String,Nothing,Screen>,privatevalnetworkCall:suspend (String)->String) : BackStackWorkflow<String, MyOutputs>() {overridesuspendfun BackStackScope.runBackStack(props:StateFlow<String>,emitOutput: (MyOutputs)->Unit  ) {// Step 1    showWorkflow(child1) { output->when (output) {"back"-> emitOutput(MyOutputs.Back)"next"-> {// Step 2val childResult= showWorkflow(child2) { output->// Removes child2 from the stack, cancels the output handler from step 1, and just// leaves child1 rendering.if (output=="back") goBack()            output          }// Step 3 – make a network call, showing a retry screen if it fails. If the user cancels// instead of retrying, we go back to showing child1.val networkResult= networkCallWithRetry(childResult)// Step 4: Show a workflow for 3 seconds then finish.          launch {            delay(3.seconds)            emitOutput(MyOutputs.Done)          }          showWorkflow(child3, flowOf(networkResult))        }else-> error("Unexpected output:$output")      }    }  }overridefuncreateIdleScreen():Screen=LoadingScreenprivatesuspendfun BackStackParentScope.networkCallWithRetry(request:String  ):String {// TODO: Show a loading screen automatically.var networkResult= networkCall(request)while (networkResult=="failure") {      showScreen {RetryScreen(          message= networkResult,          onRetryClicked= { continueWith(Unit) },// Go back to showing child1.          onCancelClicked= { goBack() }        )      }      networkResult= networkCall(request)    }return networkResult  }}

swankjesse, ekeitho, and darshanparajuli reacted with rocket emoji
@zach-klippensteinzach-klippensteinforce-pushed thezachklipp/coroutine-stepper branch 2 times, most recently frome96cb32 to4f7a1baCompareAugust 28, 2025 04:07
@zach-klippensteinzach-klippenstein changed the titlewip trying to implement jwilson's idea in workflowwip trying to implement "person as a function" in workflowAug 28, 2025
@swankjesse
Copy link
Contributor

This is exciting!

In case you missed it, the toy version of this from the talk is here:
https://github.com/swankjesse/coroutines-party-tricks/blob/main/code/lib/src/main/kotlin/com/publicobject/tricks/navigation/RealDisplay.kt

zach-klippenstein reacted with thumbs up emojizach-klippenstein reacted with eyes emoji

@zach-klippensteinzach-klippensteinforce-pushed thezachklipp/coroutine-stepper branch 2 times, most recently from2b4104a to5fc252cCompareAugust 28, 2025 19:56
* the parent passes a new props, the `showScreen` call is cancelled and called again with the
* new props, replacing the old instance of `MyScreen` in the backstack with a new one. Since
* both instances of `MyScreen` are compatible, this is not a navigation event but just updates
* the `MyScreen` view factory.
Copy link
Contributor

Choose a reason for hiding this comment

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

So cool

@zach-klippensteinzach-klippensteinforce-pushed thezachklipp/coroutine-stepper branch 5 times, most recently fromddc6b11 to9788c79CompareSeptember 1, 2025 20:36
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@swankjesseswankjesseswankjesse left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@zach-klippenstein@swankjesse

[8]ページ先頭

©2009-2025 Movatter.jp