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

[jwilson] this is a backwards-compatibility shim. Emit a simpler event. #2393

Open
github-actions bot opened this issue Oct 21, 2024 · 0 comments
Open

Comments

@github-actions
Copy link

// 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)
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants