feat: add custom context service and initializer with URL parameter support#21152
Open
npapp-dev002 wants to merge 7 commits intodevelopfrom
Open
feat: add custom context service and initializer with URL parameter support#21152npapp-dev002 wants to merge 7 commits intodevelopfrom
npapp-dev002 wants to merge 7 commits intodevelopfrom
Conversation
…rove subscription handling
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.
Claude Sonnet generated summary
[DEMO] Custom Site Context Implementation - Example for
SiteContextRoutesHandler.initOnce()ImplementationsSummary
This PR demonstrates how custom site contexts work with the new
SiteContextRoutesHandler.initOnce()pattern. This is a reference implementation and should NOT be merged.Background
This PR was created as a response to the following improvement proposal:
✅ Key Finding: Parametrization is NOT Required
After analysis, we determined that
initOnce()does NOT need acontextIdparameter because:SiteContextRoutesHandler.initOnce()handles ALL URL parameters globally by reading fromcontext.urlParametersconfigContextServiceMapand added tocontext.urlParametersWhat This PR Demonstrates
1. Custom Context Service (
CustomContextService)A derived context that wraps
LanguageServicewith uppercase transformation:2. Why Custom Contexts Don't Always Need an Initializer
Two types of custom contexts:
CustomContextService(wrapsLanguageService)For derived contexts like
CustomContextService:SiteContextRoutesHandler.initOnce()already handles URL synchronizationLanguageService) is already initializedgetActive()automatically reflects the correct value3. Reference Implementation (
CustomContextInitializer)Included as documentation for customers who need initializers for independent custom contexts.
Files Changed
custom-context-service.tscontext-service-map.tsCustomContextServiceregistrationcontext-ids.tsCUSTOMconstantapp.module.tsurlParameterssite-context-params.service.spec.tscontext-initializer-providers.tsHow Custom Contexts Work (No Parametrization Needed)
Implementation Details
📁 SiteContextRoutesHandler.initOnce()
📁 LanguageInitializer (and other initializers)
📁 Configuration Example
Conclusion
The current
initOnce()implementation without parameters is the correct design:Related Links