8000 [jwilson] this is a backwards-compatibility shim. Emit a simpler event. · Issue #2393 · cashapp/redwood · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[jwilson] this is a backwards-compatibility shim. Emit a simpler event. #2393
Open
@github-actions

Description

@github-actions

// TODO(jwilson): this is a backwards-compatibility shim. Emit a simpler event.



  override val savedStateRegistry: SavedStateRegistry? = null

  override fun contentState(loadCount: Int, attached: Boolean, uncaughtException: Throwable?) {
    // Remove all child views in case the previous content state left some behind.
    if (attached) children.views.clear()

    // Canonicalize "java.lang.Exception(boom!)" to "kotlin.Exception(boom!)".
    val exceptionString = uncaughtException?.toString()?.replace("java.lang.", "kotlin.")

    // TODO(jwilson): this is a backwards-compatibility shim. Emit a simpler event.
    eventLog += when {
      loadCount == 0 && !attached -> "codeListener.onInitialCodeLoading()"
      attached -> "codeListener.onCodeLoaded($loadCount)"
      else -> "codeListener.onCodeDetached($exceptionString)"
    }
  }

  override fun restart(restart: (() -> Unit)?) {
  }

  override fun toString() = name

  internal class FakeChildren(
    private val childrenDelegate: MutableListChildren<WidgetValue> = MutableListChildren(),
  ) : Widget.Children<WidgetValue> by childrenDelegate {
    /** A private copy of the child views that isn't cleared by `detach()`. */
    val views = mutableListOf<WidgetValue>()

    override fun insert(index: Int, widget: Widget<WidgetValue>) {
      views.add(index, widget.value)
      childrenDelegate.insert(index, widget)
    }

    override fun remove(index: Int, count: Int) {
      views.subList(index, index + count).clear()
      childrenDelegate.remove(index, count)
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0