-
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
Add the ability to update the input for a WorkflowHost. #282
Conversation
kotlin/workflow-runtime/src/main/java/com/squareup/workflow/internal/RealWorkflowHost.kt
Outdated
Show resolved
Hide resolved
kotlin/workflow-runtime/src/main/java/com/squareup/workflow/internal/RealWorkflowHost.kt
Outdated
Show resolved
Hide resolved
Would it be more useful, instead of requiring an initial input immediately and having an update function, to just only accept a stream of inputs? The workflow would then just not start until the first input was emitted. |
Yes! We've been longing for that in production already. If you're still on board with that notion I'll hold off on reviewing this for real. |
Totes. I'll update the PR asap. |
6fea2ea
to
db24454
Compare
@rjrjr Updated the API. |
Also, maybe the stream operator is too much - could just make an extension function on |
kotlin/workflow-rx2-runtime/src/main/java/com/squareup/workflow/rx2/FlatMapWorkflow.kt
Outdated
Show resolved
Hide resolved
kotlin/workflow-rx2-runtime/src/main/java/com/squareup/workflow/rx2/FlatMapWorkflow.kt
Outdated
Show resolved
Hide resolved
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.
Should inputs be an Observable converted to a Flowable with BackpressureStrategy.BUFFER internally instead?
You mean on WorkflowViewModel
, right? Flowable certainly seems like the right thing on the runtime API. WorkflowViewModel
isn't public either, though. My gut is to keep that working in terms of Flowable
, and make WorkflowActivityRunner
take an Observable
.
Also, maybe the stream operator is too much - could just make an extension function on Factory that takes an input stream and just returns a WorkflowHost. I just like the operator because the API surface is so tiny and it hides all the channel machinery completely.
No no no, I think it's a keeper. Such a natural way to think about this.
kotlin/workflow-runtime/src/main/java/com/squareup/workflow/WorkflowHost.kt
Outdated
Show resolved
Hide resolved
import kotlin.DeprecationLevel.ERROR | ||
|
||
/** | ||
* Given a stream of [InputT] values to use as inputs for the top-level [workflow], returns a |
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.
This is gorgeous.
5cf7cb6
to
44e9d41
Compare
initialSnapshot: Snapshot? = null, | ||
dispatcher: CoroutineDispatcher = Dispatchers.Unconfined | ||
): Flowable<Update<OutputT, RenderingT>> = | ||
// We're ok not having a job here because the lifetime of the coroutine will be controlled by 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.
This formatting is the auto-formatter being stupid.
A bunch of tests broke in interesting ways because things are more asynchronous now. Added |
44e9d41
to
81aa020
Compare
81aa020
to
cf3ae7b
Compare
Closes #247.