onCodeDetached

open fun onCodeDetached(app: TreehouseApp<*>, view: TreehouseView<*>, exception: Throwable?)

Invoked when the application powering view stops sending updates. This is triggered by:

  • the UI no longer needing code to drive it, perhaps because it's detached from the screen

  • the code being hot-reloaded

  • the code failing with an exception

If it is failing due to a failure, exception will be non-null and this function should display an error UI. Typical implementations call TreehouseView.reset and display an error placeholder. Development builds may show more diagnostic information than production builds.

When a Treehouse app fails, its current Zipline instance is canceled so no further code will execute. A new Zipline will start when new code available.

This condition is not permanent! If so, onCodeLoaded will be called.