workflow-kotlin icon indicating copy to clipboard operation
workflow-kotlin copied to clipboard

Android overload of renderWorkflowIn short circuits in surprising ways.

Open rjrjr opened this issue 3 years ago • 0 comments
trafficstars

The Android-specific renderWorkflowIn function is a convenience function that minimizes the fuss required to get androidx to save and restore TreeSnapshot. Because it maps our usual StateFlow<RenderingAndSnapshot> to just StateFlow<RenderingT>, it will short circuit if the root rendering type implements equals() in a naive way -- like a data class does, say. (RenderingAndSnapshot has plain old default instance equality, so this is a non-issue in our core method.)

This is pretty surprising when it happens, and hard to debug if you're not aware of StateFlow's behavior. I don't think punching up the kdoc is a reasonable answer.

I'm wondering if we can find another way to be convenient, maybe by building that snapshot handling into WorkflowLayout itself.

I'd consider this a blocker to workflow UI leaving beta.

rjrjr avatar Jun 24 '22 21:06 rjrjr