Skip to content

Consider de-emphasizing ViewRegistry. #390

@rjrjr

Description

@rjrjr

@davidapgar just caught me up on a conversation that's been happening on the Kotlin side: why not get rid of ViewRegistry?

In both the Swift and Kotlin implementations, ViewRegistry is our last remaining source of runtime errors. Meanwhile, the indirection it provides is probably redundant with that already provided by having no restrictions on the workflow rendering type.

Swift already has a Screen marker interface, with a method that makes a screen responsible for instantiating its own ViewController. Isn't that enough?

  • Android could just as easily have a Screen.buildView interface / method. That should still work nicely with the new LayoutRunner and ViewShowRendering code introduced in Hello LayoutRunner, goodbye Coordinator, BackStackEffect. #383 .
  • Headless workflows aren't forced to use it as their rendering type
  • It'd be easy enough to use mapRendering, or provide a mapViewController method

The only downside we see is that a workflow's view classes become a public concern. That doesn't seem like much of an issue for internal code.

For public code, e.g. a workflow-based library that might want to allow clients to bind its own view code and for which "default" view classes could be a wart, ViewRegistry could be revived as a tool for use within a root workflow. That's practically what's happening inside WorkflowLayout / ContainerViewController already.

Metadata

Metadata

Assignees

No one assigned

    Labels

    swiftAffects the Swift library.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions