feat(common): introduce StateTransferInitializerModule#916
feat(common): introduce StateTransferInitializerModule#916Toxicable merged 1 commit intoangular:masterfrom
Conversation
| @@ -0,0 +1,13 @@ | |||
| # State Transfer Initializer | |||
| Delays the app bootstrap proces to ensure that the DOM content is loaded before | |||
There was a problem hiding this comment.
/s/proces/process
Also the thought trails off, maybe "before state transfer initialization"
| # State Transfer Initializer | ||
| Delays the app bootstrap proces to ensure that the DOM content is loaded before | ||
|
|
||
| Simply import the module into your project and you will not longer need to wrap your component bootsrap function in an `DOMContentLoaded` callback |
There was a problem hiding this comment.
/s/not/no
/s/bootsrap/bootstrap
/s/an/a
| import { NgModule } from '@angular/core'; | ||
|
|
||
| export function domContentLoadedFactory(doc: Document) { | ||
| return () => { |
There was a problem hiding this comment.
Can't this function take a Promise directly, ie cut out the inner return?
There was a problem hiding this comment.
Pretty sure it takes a fn which returns a Promise.
Will double check
There was a problem hiding this comment.
There was a problem hiding this comment.
That example has the signature:
() => Promise<>
So here it would be:
return () => new Promise((resolve, reject) => {});There was a problem hiding this comment.
I'm saying get rid of the first pair of curly braces
There was a problem hiding this comment.
I mean, it dosen't change anything but sure
| return new Promise ((resolve, reject) => { | ||
| const contentLoaded = () => { | ||
| resolve(); | ||
| doc.removeEventListener('DOMContentLoaded', contentLoaded); |
There was a problem hiding this comment.
Should this come before the resolve?
|
|
||
| @NgModule({ | ||
| providers: [ | ||
| {provide: APP_INITIALIZER, multi: true, useFactory: domContentLoadedFactory, deps: [DOCUMENT]}, |
There was a problem hiding this comment.
Missed this:
Missing import for DOCUMENT
| {provide: APP_INITIALIZER, multi: true, useFactory: domContentLoadedFactory, deps: [DOCUMENT]}, | ||
| ] | ||
| }) | ||
| export class StateTransferInitializerModule |
There was a problem hiding this comment.
Also missing curly braces here
There was a problem hiding this comment.
I figured we'd add testing in a follow-up PR once we iron out our testing scheme
There was a problem hiding this comment.
yupyup that was my plan aswell
There was a problem hiding this comment.
I mean silly thiongs like that would be picked up there
| resolve(); | ||
| }; | ||
| doc.addEventListener('DOMContentLoaded', contentLoaded); | ||
| }; |
6696d31 to
50d9ac1
Compare
50d9ac1 to
55d159a
Compare
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Adds a new module to help with StateTransfer
What is the current behavior? (You can also link to an open issue here)
n/a
What is the new behavior (if this is a feature change)?
Adds a new module to delay the app starting, therefore delay statetransfer accessing the dom till it's ready