feat(routes): add registered route lifecycle observer - #16
Open
Upd4ting wants to merge 5 commits into
Open
Conversation
Expose a replayable multicast lifecycle API for complete route handlers without attaching another provider to the internal registering proxy. Keep explicit removals and module unloads synchronized with the public observer.
Snapshot live subscribers so nested subscriptions do not receive duplicate events. Skip stale replay entries removed by earlier observer callbacks.
Member
Author
|
@greptile review |
Track observer subscription generations so callbacks removed during an emission are skipped, including remove-and-resubscribe sequences.
Member
Author
|
@greptile review |
Revalidate the route before each live registration callback so reentrant removal cannot leave later observer caches stale.
Member
Author
|
@greptile review |
Reuse one active subscription per observer identity so either unsubscribe handle stops future notifications without weakening reentrant generation checks.
Member
Author
|
@greptile review |
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.
Summary
RegisteredRoutesObserverandObserveRegisteredRoutes(observer): () => voidRouteHandlerobjects, then multicast registrations and removals@antelopejs/api@1.2.4Motivation
cms-apineeds complete route handlers to maintain its route cache. It currently relies on the internalroutesProxy.onRegisterandonUnregistermethods. Under Core 1.5, that registering proxy is a provider-routing slot rather than a multicast event source, so a direct subscriber can fail withMissingProviderError, compete with the real API provider, or remain inert.getRegisteredRoutes()cannot replace this usage because it omits handler mode, callback, and prototype.The new public observer is owned by
interface-apiand uses its existingroutesListsource of truth without exposing proxy internals.Validation
pnpm lintpnpm buildpnpm test— 92 passing with Core 1.4.7 / interface-core 0.0.8 and@antelopejs/api@1.2.4pnpm publish --dry-run --no-git-checksThe planned release is 0.0.13; this PR intentionally does not bump the package version.
Greptile Summary
The PR adds a public registered-route lifecycle observer that synchronously replays complete handlers and multicasts subsequent registrations and removals while isolating callback failures.
@antelopejs/api@1.2.4.Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
@antelopejs/api@1.2.4.Sequence Diagram
sequenceDiagram participant Consumer participant ObserverAPI as ObserveRegisteredRoutes participant Routes as routesList participant Proxy as routesProxy Consumer->>ObserverAPI: Subscribe(observer) ObserverAPI->>Routes: Snapshot existing handlers loop Existing registered routes ObserverAPI-->>Consumer: onRegister(id, handler) end Proxy->>Routes: Add registered handler Proxy->>ObserverAPI: Notify registration ObserverAPI-->>Consumer: onRegister(id, handler) Proxy->>Routes: Remove handler Proxy->>ObserverAPI: Notify removal ObserverAPI-->>Consumer: onUnregister(id)Reviews (5): Last reviewed commit: "fix(routes): deduplicate repeated observ..." | Re-trigger Greptile