-
Notifications
You must be signed in to change notification settings - Fork 101
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
Conversation
3d26c90
to
784bd7a
Compare
…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.
784bd7a
to
505af7e
Compare
@Suppress("DEPRECATION") | ||
@Deprecated("Implement Updater.apply") | ||
fun Mutator<StateT>.apply(): OutputT? { | ||
throw UnsupportedOperationException() | ||
} | ||
|
There was a problem hiding this comment.
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.
* | ||
* 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]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sample use?
There was a problem hiding this comment.
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.
There was a problem hiding this 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)" }) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
Make ViewFactory.showRendering function responsible for applying the ComposeViewFactoryRoot.
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
UI Tests