Repository navigation
Add an explicit root lifecycle seam for backends - #13
Merged
Merged
Conversation
isaksky
force-pushed
the
lifecycle-seam
branch
from
October 16, 2026 01:25
639a598 to
0b0aa4d
Compare
isaksky
force-pushed
the
reconciler-subscriptions
branch
from
October 16, 2026 01:25
c7078b7 to
3b0272a
Compare
isaksky
marked this pull request as draft
October 16, 2026 01:39
Member
|
yeah that's a reasonable addition as well |
isaksky
force-pushed
the
lifecycle-seam
branch
from
October 16, 2026 03:28
0b0aa4d to
bc04b4f
Compare
isaksky
force-pushed
the
reconciler-subscriptions
branch
from
October 16, 2026 03:28
3b0272a to
886e193
Compare
A backend that owns native resources can implement :run-lifecycle and receive :mount!, :unmount! and :abandon! callbacks, instead of relying on the value the mount-root! callback happens to return. :dispose! lets the core hand back a widget it created but could not attach, and glimmer.core/abandon! detaches a mounted root's subscriptions without native calls, for roots a backend mounts itself when the native side is already gone. run now detaches the root's subscriptions when it returns, including for legacy :run backends, and a reload queued before a run exits cannot touch a later run. A later run replaces the live root, as before, but only once its own root has mounted, so a run the backend rejects before that (Qt refuses a second session) leaves the live run's reload! target in place; and a reload whose new root throws while mounting keeps the run's window and previous root fn, so a later reload! fills the window instead of finding nothing to reload. The lifecycle tests also cover the exceptional exits the seam exists for: a legacy loop that throws still has its root detached and live-root released, and abandon! detaches a run's subscriptions at once without a native call, through a re-render queued before it and run's finalizer alike, leaving unmount!, abandon! and reload! as no-ops. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
isaksky
force-pushed
the
reconciler-subscriptions
branch
from
October 16, 2026 04:11
886e193 to
ee93a5c
Compare
isaksky
force-pushed
the
lifecycle-seam
branch
from
October 16, 2026 04:11
bc04b4f to
12ea99a
Compare
isaksky
marked this pull request as ready for review
October 17, 2026 01:36
Contributor
Author
|
Ready to be looked at. |
glimmer-appkit keeps the value its :run backend gets from mount-root! and reads :inst off it for root-inst; returning nil broke that.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #12; review the second commit only.
A backend that owns native resources, such as Qt, needs to unmount the root on its UI thread before destroying the container, and to drop the root's subscriptions when the native side has already gone. The
:runcontract offers neither: the only handle on the mounted root was whatever themount-root!callback happened to return.:run-lifecycle (fn [opts lifecycle])is an optional backend op that receives:mount!,:unmount!and:abandon!thunks and owns the root's lifetime. Backends implementing:runare unaffected;runfalls back to it.:dispose!lets the core hand back a widget it created but could not attach.glimmer.core/abandon!detaches a mounted root's subscriptions without native calls, for roots a backend mounts itself withmount.runnow detaches the root's subscriptions when it returns, including for legacy:runbackends. Previously the old tree stayed subscribed todefoncecells after the app quit.runreplaces the live root, as before, but only once its own root has mounted. A run the backend rejects before that, as Qt does for a second session, leaves the live run'sreload!target in place.reload!fills the window instead of finding nothing to reload. A reload queued before a run exits cannot touch a later run.The README gains the two ops in the backend map and a Lifecycle paragraph. Tests are in
test/glimmer/lifecycle_test.clj, including the exceptional exits the seam exists for: a legacy loop that throws still has its root detached and the live root released, andabandon!detaches a run's subscriptions at once without a native call, through a re-render queued before it andrun's finalizer alike, leavingunmount!,abandon!andreload!as no-ops. The Qt backend in glimmer-qt is the first consumer of the seam.🤖 Generated with Claude Code