-
Notifications
You must be signed in to change notification settings - Fork 69
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
Pass the workflow's scope into initialState. #286
Conversation
3681e12
to
d12edba
Compare
d12edba
to
1d57b5d
Compare
*/ | ||
abstract fun initialState( | ||
input: InputT, | ||
snapshot: Snapshot? | ||
snapshot: Snapshot?, | ||
scope: CoroutineScope |
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.
@davidapgar @bencochran @timdonnelly Seems like we should be able to come up with a similar object to pass into the analogous method in Swift — basically something that can accept tearDown duties instead of the method on WorkflowContext.
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'm not suggesting this is a good direction, but if Swift wanted to match this as accurately as possible, it would be a teardown hook plus a scheduler. Having access to a coroutine scope is useful for us, but given the lack of similar concepts in Swift I'm not sure this would be the best API for them. But curious to hear what yall think!
@@ -71,10 +73,15 @@ abstract class StatefulWorkflow< | |||
* If the workflow is being restored from a [Snapshot], [snapshot] will be the last value | |||
* returned from [snapshotState], and implementations that return something other than | |||
* [Snapshot.EMPTY] should create their initial state by parsing their snapshot. | |||
* @param scope | |||
* The [CoroutineScope] in which this workflow lives. The scope will be cancelled when the |
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.
Can we provide an example of how to use it?
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'm not sure what kind of example would be useful. It's basically only there to support Worker
s (which users don't need to care about unless they want to look at source directly), or cancellation of some external resource, and I don't even know yet what the best way will be to use this scope to cancel those. I'll file an issue to track improving this doc as we go forward: #290.
Closes #288.