forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(compiler): introduce defer trigger instructions (angular#51315)
Adds the logic for generating the instructions for the various deferred triggers. PR Close angular#51315
- Loading branch information
1 parent
79f9d49
commit 5212b47
Showing
18 changed files
with
444 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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
20 changes: 20 additions & 0 deletions
20
...i/test/compliance/test_cases/r3_view_compiler_deferred/deferred_with_prefetch_triggers.ts
This file contains 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,20 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
@Component({ | ||
template: ` | ||
{{message}} | ||
{#defer prefetch when isVisible() || isReady; prefetch on idle, timer(1337); | ||
prefetch on immediate, hover; prefetch on interaction(button); prefetch on viewport(button)} | ||
{{message}} | ||
{:placeholder}<button #button>Click me</button> | ||
{/defer} | ||
`, | ||
}) | ||
export class MyApp { | ||
message = 'hello'; | ||
isReady = true; | ||
|
||
isVisible() { | ||
return false; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...mpliance/test_cases/r3_view_compiler_deferred/deferred_with_prefetch_triggers_template.js
This file contains 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,20 @@ | ||
function MyApp_Template(rf, ctx) { | ||
if (rf & 1) { | ||
$r3$.ɵɵtext(0); | ||
$r3$.ɵɵtemplate(1, MyApp_Defer_1_Template, 1, 1); | ||
$r3$.ɵɵtemplate(2, MyApp_DeferPlaceholder_2_Template, 3, 0); | ||
$r3$.ɵɵdefer(3, 1, null, null, 2); | ||
$r3$.ɵɵdeferOnIdle(); | ||
$r3$.ɵɵdeferPrefetchOnIdle(); | ||
$r3$.ɵɵdeferPrefetchOnImmediate(); | ||
$r3$.ɵɵdeferPrefetchOnTimer(1337); | ||
$r3$.ɵɵdeferPrefetchOnHover(); | ||
$r3$.ɵɵdeferPrefetchOnInteraction("button"); | ||
$r3$.ɵɵdeferPrefetchOnViewport("button"); | ||
} | ||
if (rf & 2) { | ||
$r3$.ɵɵtextInterpolate1(" ", ctx.message, " "); | ||
$r3$.ɵɵadvance(3); | ||
$r3$.ɵɵdeferPrefetchWhen(ctx.isVisible() || ctx.isReady); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...mpiler-cli/test/compliance/test_cases/r3_view_compiler_deferred/deferred_with_triggers.ts
This file contains 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,20 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
@Component({ | ||
template: ` | ||
{{message}} | ||
{#defer when isVisible() || isReady; on idle, timer(1337); on immediate, hover; | ||
on interaction(button); on viewport(button)} | ||
{{message}} | ||
{:placeholder}<button #button>Click me</button> | ||
{/defer} | ||
`, | ||
}) | ||
export class MyApp { | ||
message = 'hello'; | ||
isReady = true; | ||
|
||
isVisible() { | ||
return false; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...i/test/compliance/test_cases/r3_view_compiler_deferred/deferred_with_triggers_template.js
This file contains 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,19 @@ | ||
function MyApp_Template(rf, ctx) { | ||
if (rf & 1) { | ||
$r3$.ɵɵtext(0); | ||
$r3$.ɵɵtemplate(1, MyApp_Defer_1_Template, 1, 1); | ||
$r3$.ɵɵtemplate(2, MyApp_DeferPlaceholder_2_Template, 3, 0); | ||
$r3$.ɵɵdefer(3, 1, null, null, 2); | ||
$r3$.ɵɵdeferOnIdle(); | ||
$r3$.ɵɵdeferOnImmediate(); | ||
$r3$.ɵɵdeferOnTimer(1337); | ||
$r3$.ɵɵdeferOnHover(); | ||
$r3$.ɵɵdeferOnInteraction("button"); | ||
$r3$.ɵɵdeferOnViewport("button"); | ||
} | ||
if (rf & 2) { | ||
$r3$.ɵɵtextInterpolate1(" ", ctx.message, " "); | ||
$r3$.ɵɵadvance(3); | ||
$r3$.ɵɵdeferWhen(ctx.isVisible() || ctx.isReady); | ||
} | ||
} |
This file contains 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
Oops, something went wrong.