Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

feat(common): introduce StateTransferInitializerModule#916

Merged
Toxicable merged 1 commit intoangular:masterfrom
Toxicable:state-transfer-init
Mar 10, 2018
Merged

feat(common): introduce StateTransferInitializerModule#916
Toxicable merged 1 commit intoangular:masterfrom
Toxicable:state-transfer-init

Conversation

@Toxicable
Copy link
Copy Markdown

  • Please check if the PR fulfills these requirements
- [x] The commit message follows
- [ ] Tests for the changes have been added (for bug fixes / features)
- [x] Docs have been added / updated (for bug fixes / features)
  • What modules are related to this pull-request
- [x] common
  • 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

@@ -0,0 +1,13 @@
# State Transfer Initializer
Delays the app bootstrap proces to ensure that the DOM content is loaded before
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/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
Copy link
Copy Markdown
Member

@CaerusKaru CaerusKaru Mar 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/s/not/no
/s/bootsrap/bootstrap
/s/an/a

import { NgModule } from '@angular/core';

export function domContentLoadedFactory(doc: Document) {
return () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this function take a Promise directly, ie cut out the inner return?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure it takes a fn which returns a Promise.
Will double check

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That example has the signature:

() => Promise<>

So here it would be:

return () => new Promise((resolve, reject) => {});

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what im doing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm saying get rid of the first pair of curly braces

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, it dosen't change anything but sure

return new Promise ((resolve, reject) => {
const contentLoaded = () => {
resolve();
doc.removeEventListener('DOMContentLoaded', contentLoaded);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this come before the resolve?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

@Toxicable Toxicable changed the title feat(common): introduce StateTransferInitializerModule [WIP]feat(common): introduce StateTransferInitializerModule Mar 7, 2018
Copy link
Copy Markdown
Member

@CaerusKaru CaerusKaru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


@NgModule({
providers: [
{provide: APP_INITIALIZER, multi: true, useFactory: domContentLoadedFactory, deps: [DOCUMENT]},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed this:

Missing import for DOCUMENT

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:P

@Toxicable Toxicable added the target: minor target: minor This PR is targeted for the next minor release label Mar 7, 2018
{provide: APP_INITIALIZER, multi: true, useFactory: domContentLoadedFactory, deps: [DOCUMENT]},
]
})
export class StateTransferInitializerModule
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also missing curly braces here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs testing yo

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured we'd add testing in a follow-up PR once we iron out our testing scheme

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yupyup that was my plan aswell

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean silly thiongs like that would be picked up there

@CaerusKaru CaerusKaru added this to the 6.0 milestone Mar 7, 2018
resolve();
};
doc.addEventListener('DOMContentLoaded', contentLoaded);
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing closing parens

@Toxicable Toxicable force-pushed the state-transfer-init branch from 6696d31 to 50d9ac1 Compare March 7, 2018 17:13
@Toxicable Toxicable changed the title [WIP]feat(common): introduce StateTransferInitializerModule feat(common): introduce StateTransferInitializerModule Mar 7, 2018
@Toxicable Toxicable force-pushed the state-transfer-init branch from 50d9ac1 to 55d159a Compare March 10, 2018 03:43
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: review target: minor target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants