Skip to content
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

RedwoodView should not have Treehouse lifecycle #2392

Open
JakeWharton opened this issue Oct 21, 2024 · 1 comment
Open

RedwoodView should not have Treehouse lifecycle #2392

JakeWharton opened this issue Oct 21, 2024 · 1 comment
Assignees

Comments

@JakeWharton
Copy link
Collaborator

This class is meant to provide a frame and integrations to the platform UI toolkit. The Treehouse loading/error stuff should exist entirely at the Treehouse layer and render within the frame–not as part of it.

Related to #1475.

@squarejesse
Copy link
Contributor

I have a plan:

RedwoodView

I’m going to make loading & error screens children of the RedwoodView, rather than states of the RedwoodView:

public interface DynamicContentWidgetFactory<W : Any> {
  public fun Loading(): Widget
  public fun Crashed(throwable: Throwable): Widget
}

I’ll need to create a default implementation that uses an empty widget.

Observing Content State

With the above I still want to notify the host of code reloads and detached content. I’ll do that separately, with a new Content.State sealed class and a new property on Content:

public interface Content {
  public val state: StateFlow<State>

  sealed class State {
    public data object Detached : ContentState()
    public data object Loading : ContentState()
    public data class Attached(val loadCount: Int) : ContentState()
    public data class Crashed(val uncaughtException: Throwable): ContentState()
  }
}

Redundant?

One thing I struggled with was exposing states like Loading two ways: as a child element and as a StateFlow. But I think it’s the best option for giving the application the power to put loading state in the UI or not. We need that power in Cash App!

It should also let us avoid detaching the root view’s children, which is currently super awkward.

@squarejesse squarejesse self-assigned this Oct 28, 2024
swankjesse added a commit that referenced this issue Oct 31, 2024
* Split Treehouse lifecycle out of RedwoodView

#2392

* More test coverage for bind lifecycle

* Track API changes in emoji-search

* Track API changes in iOS samples

---------

Co-authored-by: Jesse Wilson <jwilson@squareup.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants