Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
feat(platform-server): provide a way to hook into renderModule* #19023
A multi BEFORE_APP_SERIALIZED provider can provide function that will be called with the current document just before the document is rendered to
This hook can for example be used for the state transfer module to serialize any server state that needs to be transported to the client, just before the current platform state is rendered to string.
Please check if your PR fulfills the following requirements:
What kind of change does this PR introduce?
What is the current behavior?
When using the renderModule* functions from @angular/platform-server there is no way to change the document state after the app is stable but before the current document is serialized to string.
Issue Number: N/A
What is the new behavior?
Users can provide a RENDER_MODULE_HOOK multi-provider that can insert/change document state just before it is rendered.
Does this PR introduce a breaking change?
Maybe add in support for async function returns like the one I did here https://github.com/angular/angular/pull/19010/files#diff-d6389d42fc011e1bb9b5f6ea6e66faf0R48
@Toxicable - Ah - We should have sync-ed to avoid duplication. I don't we should be adding more async stuff to the system without proper use case. Also what if the render hook makes the Angular application unstable again? All the async stuff can be done and gated behind the isStable and the render hook should just do sync work.
I'm always on https://gitter.im/angular/angular if you want an update on what im working on.
This is so that modules like state transfer or meta tags adding code can run after isStable but before the final document state is serialized. It is not for avoiding isStable and shouldn't be doing async tasks like http fetch, but just for adding script/meta tags to the document just before it's serialized