square / workflow-kotlin

A Swift and Kotlin library for making composable state machines, and UIs driven by those state machines.

Home Page:https://square.github.io/workflow

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consider removing `ViewEnvironment` parameter from `RenderWorkflowIn`

rjrjr opened this issue · comments

Look at the anxious section at the end of the original Compose integration writeup. We mainly rationalized passing ViewEnvironment around because it was so fragile WRT ViewRegistry -- things would blow up if there was no ViewRegistry in ViewEnvironment, that kind of thing.

This is no longer the case. ViewRegistry is very much optional, and having a missing or empty one is just fine. And the manually passed ViewEnvironment has been a chronic optmization problem. Maybe we should undo that decision, and make ViewEnvironment just another Compose local.

val LocalWorkflowEnvironment = staticCompositionLocalOf<ViewEnvironment> {
    noLocalProvidedFor("LocalView")
}