Repository navigation
feat(aio): lazy-load embedded components #18428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0924132
feat(aio): lazy-load embedded components
gkalpak 4cc6998
fix(aio): do not show new document until embedded components are ready
gkalpak 7d7750e
feat(aio): animate the leaving/entering documents
gkalpak d3dcf03
fix(aio): fix embedded ToC and improve ToC, destroying components and…
gkalpak d6f0a66
build(aio): upgrade to latest `rxjs`
gkalpak 3dbfd32
build(aio): upgrade to latest `@angular/*`
gkalpak 1b774ce
build(aio): upgrade to latest `@angular/material` and `@angular/cdk`
gkalpak 2d6ed50
build(aio): upgrade to latest `@angular/cli`
gkalpak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
feat(aio): lazy-load embedded components
Fixes #16127
- Loading branch information
commit 0924132092891bb363c17486856169fc06394ce7
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { TestBed } from '@angular/core/testing'; | ||
| import { AppModule } from 'app/app.module'; | ||
| import { ComponentsOrModulePath, EMBEDDED_COMPONENTS } from 'app/embed-components/embed-components.service'; | ||
| import { embeddedComponents } from 'app/embedded/embedded.module'; | ||
|
|
||
| describe('AppModule', () => { | ||
| let componentsMap: {[multiSelectorstring: string]: ComponentsOrModulePath}; | ||
|
|
||
| beforeEach(() => { | ||
| TestBed.configureTestingModule({imports: [AppModule]}); | ||
| componentsMap = TestBed.get(EMBEDDED_COMPONENTS); | ||
| }); | ||
|
|
||
| it('should provide a map of selectors to embedded components (or module)', () => { | ||
| const allSelectors = Object.keys(componentsMap); | ||
|
|
||
| expect(allSelectors.length).toBeGreaterThan(1); | ||
| allSelectors.forEach(selector => { | ||
| const value = componentsMap[selector]; | ||
| const isArrayOrString = Array.isArray(value) || (typeof value === 'string'); | ||
| expect(isArrayOrString).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| it('should provide a list of eagerly-loaded embedded components', () => { | ||
| const eagerSelector = Object.keys(componentsMap).find(selector => Array.isArray(componentsMap[selector])); | ||
| const selectorCount = eagerSelector.split(',').length; | ||
|
|
||
| expect(eagerSelector).not.toBeNull(); | ||
| expect(selectorCount).toBe(componentsMap[eagerSelector].length); | ||
|
|
||
| // For example... | ||
| expect(eagerSelector).toContain('aio-toc'); | ||
| }); | ||
|
|
||
| it('should provide a list of lazy-loaded embedded components', () => { | ||
| const lazySelector = Object.keys(componentsMap).find(selector => selector.includes('code-example')); | ||
| const selectorCount = lazySelector.split(',').length; | ||
|
|
||
| expect(lazySelector).not.toBeNull(); | ||
| expect(selectorCount).toBe(embeddedComponents.length); | ||
|
|
||
| // For example... | ||
| expect(lazySelector).toContain('code-example'); | ||
| expect(lazySelector).toContain('code-tabs'); | ||
| expect(lazySelector).toContain('live-example'); | ||
| }); | ||
| }); |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { NgModule, NgModuleFactoryLoader, SystemJsNgModuleLoader } from '@angular/core'; | ||
|
|
||
| import { EmbedComponentsService } from './embed-components.service'; | ||
|
|
||
|
|
||
| @NgModule({ | ||
| providers: [ | ||
| EmbedComponentsService, | ||
| { provide: NgModuleFactoryLoader, useClass: SystemJsNgModuleLoader }, | ||
| ], | ||
| }) | ||
| export class EmbedComponentsModule { | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what you are saying is that
TocComponentis not lazy loaded, but it needs to be made available as an embedded component?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. Because we use it on the page (outside of
DocViewer) for displaying the ToC on the right (for large screens), but also as embedded component to show it on narrow screens.