[PR #302] [CLOSED] feat: improve lifecycle management #1217

Closed
opened 2026-03-14 09:24:49 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opentui/pull/302
Author: @limwa
Created: 11/11/2025
Status: Closed

Base: mainHead: feat/improve-lifecycle-management


📝 Commits (7)

  • 9b016fe feat(renderer): add exit signals option
  • e6138c2 refactor(react): make renderer accessible from render
  • 454d001 refactor(solid): make renderer accessible from render
  • 3dbe570 refactor(solid): replace render with createRoot
  • 3887bb9 refactor(core): simplify exit signal handling logic
  • 5ca7270 fix(core): capture dump on exit
  • 02085e4 chore(solid): remove render import from examples

📊 Changes

8 files changed (+96 additions, -47 deletions)

View changed files

📝 packages/core/src/renderer.ts (+29 -9)
📝 packages/react/src/reconciler/renderer.ts (+6 -10)
📝 packages/solid/README.md (+3 -1)
📝 packages/solid/examples/index.tsx (+6 -5)
📝 packages/solid/examples/repro-empty-styled-text.tsx (+4 -3)
📝 packages/solid/examples/repro-filter-list.tsx (+4 -2)
📝 packages/solid/examples/repro-onSubmit.tsx (+4 -2)
📝 packages/solid/index.ts (+40 -15)

📄 Description

Fixes #248.

Changes

Core

  • Adds new exitSignals option to renderer, which specifies a list of signals that the renderer should destroy itself upon receiving.
    • The handlers are mounted when the renderer is created or resumed, and are unmounted when the renderer is suspended.
  • The exit handler is now run on the beforeExit event. The exit event does not allow for more tasks to be added to the event loop, and thus the Bun.sleep(200) call would be effectively ignored, preventing the captured logs from being dumped.

React

  • Deduplicates repeated logic between the createRoot and render methods.
  • Exposes the renderer on the render methods to make it easier to implement external lifecycle control.

Solid

  • Exposes the renderer on the render methods to make it easier to implement external lifecycle control.
  • Applies the changes from #270 to the @opentui/solid package as well. This is helpful for lifecycle control because it inherently exposes the renderer (the user has to create one beforehand).
    • A createRoot method already exists in the solid-js package, which could create some confusion. Should I rename it? Open to suggestions!
    • Also updated all @opentui/solid examples and README.md to reflect the new API.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opentui/pull/302 **Author:** [@limwa](https://github.com/limwa) **Created:** 11/11/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/improve-lifecycle-management` --- ### 📝 Commits (7) - [`9b016fe`](https://github.com/anomalyco/opentui/commit/9b016fe082112a3f9bb564cee1374fd4410d5100) feat(renderer): add exit signals option - [`e6138c2`](https://github.com/anomalyco/opentui/commit/e6138c250e173dd154d785e4ed03449ea6d5859b) refactor(react): make renderer accessible from render - [`454d001`](https://github.com/anomalyco/opentui/commit/454d00107adae42bf67992ebe7c9fe69c9c8b95c) refactor(solid): make renderer accessible from render - [`3dbe570`](https://github.com/anomalyco/opentui/commit/3dbe57087b5231278a6c6a2e849ad1f03fc0c310) refactor(solid): replace render with createRoot - [`3887bb9`](https://github.com/anomalyco/opentui/commit/3887bb91c23af44586b00d97a193ed616f947a8c) refactor(core): simplify exit signal handling logic - [`5ca7270`](https://github.com/anomalyco/opentui/commit/5ca7270665dd0da2e2595ba9d153ef17a7f57752) fix(core): capture dump on exit - [`02085e4`](https://github.com/anomalyco/opentui/commit/02085e43d09cebca6c9cd1279bb841319e29d33b) chore(solid): remove render import from examples ### 📊 Changes **8 files changed** (+96 additions, -47 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/renderer.ts` (+29 -9) 📝 `packages/react/src/reconciler/renderer.ts` (+6 -10) 📝 `packages/solid/README.md` (+3 -1) 📝 `packages/solid/examples/index.tsx` (+6 -5) 📝 `packages/solid/examples/repro-empty-styled-text.tsx` (+4 -3) 📝 `packages/solid/examples/repro-filter-list.tsx` (+4 -2) 📝 `packages/solid/examples/repro-onSubmit.tsx` (+4 -2) 📝 `packages/solid/index.ts` (+40 -15) </details> ### 📄 Description Fixes #248. ## Changes ### Core - Adds new `exitSignals` option to renderer, which specifies a list of signals that the renderer should destroy itself upon receiving. - The handlers are mounted when the renderer is created or resumed, and are unmounted when the renderer is suspended. - The exit handler is now run on the `beforeExit` event. The `exit` event does not allow for more tasks to be added to the event loop, and thus the `Bun.sleep(200)` call would be effectively ignored, preventing the captured logs from being dumped. ### React - Deduplicates repeated logic between the `createRoot` and `render` methods. - Exposes the renderer on the `render` methods to make it easier to implement external lifecycle control. ### Solid - Exposes the renderer on the `render` methods to make it easier to implement external lifecycle control. - Applies the changes from #270 to the `@opentui/solid` package as well. This is helpful for lifecycle control because it inherently exposes the `renderer` (the user has to create one beforehand). - A `createRoot` method already exists in the `solid-js` package, which could create some confusion. Should I rename it? Open to suggestions! - Also updated all `@opentui/solid` examples and README.md to reflect the new API. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-14 09:24:49 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#1217
No description provided.