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

Introduce helpers for working with Sinks of WorkflowActions from suspend functions. #24

Merged
merged 1 commit into from
Jun 23, 2020

Conversation

zach-klippenstein
Copy link
Collaborator

@zach-klippenstein zach-klippenstein commented Jun 18, 2020

  • Sink.sendAndAwaitApplication()
  • Flow.collectToSink()

These helpers will be used to implement Workers using side effects (#12).
GUWT workers are described in square/workflow#1021.

Checklist

  • Unit Tests
  • UI Tests
  • I have made corresponding changes to the documentation

@zach-klippenstein zach-klippenstein force-pushed the zachklipp/collect-to-sink branch 4 times, most recently from 3d26c90 to 784bd7a Compare June 19, 2020 01:31
@zach-klippenstein zach-klippenstein changed the title WIP Introduce Flow.collectToActionSink to prepare for GUWT workers. Introduce helpers for working with Sinks of WorkflowActions from suspend functions. Jun 19, 2020
@zach-klippenstein zach-klippenstein added the enhancement New feature or request label Jun 19, 2020
@zach-klippenstein zach-klippenstein marked this pull request as ready for review June 19, 2020 01:33
@zach-klippenstein zach-klippenstein requested a review from a team as a code owner June 19, 2020 01:33
…end functions.

- `Sink.sendAndAwaitApplication()`
- `Flow.collectToSink()`

These helpers will be used to implement Workers using side effects (#12).
GUWT workers are described in square/workflow#1021.
Comment on lines +58 to +63
@Suppress("DEPRECATION")
@Deprecated("Implement Updater.apply")
fun Mutator<StateT>.apply(): OutputT? {
throw UnsupportedOperationException()
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved this method below the non-deprecated one so that the non-deprecated one is what gets resolved for WorkflowAction.apply links in kdoc.

@zach-klippenstein zach-klippenstein added this to the v1.0.0 milestone Jun 20, 2020
*
* If this coroutine is cancelled before the action gets applied, the action will not be applied.
*
* This method is intended to be used from [RenderContext.runningSideEffect].
Copy link
Contributor

Choose a reason for hiding this comment

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

sample use?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure what value a sample would add: there's really only one possible way to use this method.

@zach-klippenstein zach-klippenstein merged commit 42636c6 into main Jun 23, 2020
@zach-klippenstein zach-klippenstein deleted the zachklipp/collect-to-sink branch June 23, 2020 20:28
Copy link
Contributor

@steve-the-edwards steve-the-edwards left a comment

Choose a reason for hiding this comment

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

I found the tests very edifying - neat way of doing it! One naming thing.

action: WorkflowAction<StateT, OutputT>
) {
suspendCancellableCoroutine<Unit> { continuation ->
val resumingAction = action<StateT, OutputT>({ "sendAndAwaitExecution($action)" }) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Don't you want the name to be sendAndAwaitApplication?

@Test fun `collectToActionSink sends action`() {
runBlockingTest {
val flow = MutableStateFlow(1)
val collector = launch {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: collector is slightly overloaded here given the coroutine context. Maybe sinkCollector? or collectorJob?

zach-klippenstein added a commit that referenced this pull request Feb 4, 2021
Make ViewFactory.showRendering function responsible for applying the ComposeViewFactoryRoot.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants