-
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
1249: Cache Intercepted Workflow Instance #1250
Conversation
1c12e26
to
1bf6f2f
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
1bf6f2f
to
a7dab3d
Compare
a7dab3d
to
8e40b8a
Compare
@@ -202,6 +205,18 @@ internal class WorkflowNode<PropsT, StateT, OutputT, RenderingT>( | |||
coroutineContext.cancel(cause) | |||
} | |||
|
|||
// Call this after we have been passed any workflow instance, in [render] or [snapshot]. It may | |||
// have changed and we should check to see if we need to update our cached instances. |
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: Make this a kdoc comment so it's visible directly at callsites.
if (workflow !== cachedWorkflowInstance) { | ||
// instance has changed. | ||
interceptedWorkflowInstance = interceptor.intercept(workflow, this) | ||
cachedWorkflowInstance = workflow |
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.
Why do you update cachedWorkflowInstance
first in init
, but second here? Is there some case where intercept
needs the cached workflow to not be updated yet?
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.
nope. Just a coincidence. I can unify the order so its not confusing.
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.
Done.
Change it if we have been passed a new workflow instance to the same node.
8e40b8a
to
2e43d2c
Compare
We cache the instance of the workflow before and after it is intercepted.
We check for instance equality any time a new workflow instance is passed in (
render()
andsnapshot()
) and we update our cached instances when that happens. This will allow us to continue to use the sameWorkflowNode
with different instances of the workflow.Closes #1249