There are two ways of how we can migrate existing Angular applications to
the new ViewChild
and ContentChild
static timing syntax. Either by:
Both approaches have benefits and downsides which are summarized here:
Approach 1 (query usage)
Positives:
ContentChild
query timing if used statically (for most cases: see negatives)Negatives:
fixture.detectChanges
Approach 2 (template selection)
Positives:
ViewQuery
due to the template analysis.Negatives:
ContentChild
since projected content canWe analyze the query usage and check if we find a static
query usage. If we
definitely found a static query usage, we mark the query as static.
If we are unsure about it being static (e.g. through a third-party callback function), the
query timing is ambiguous and we mark it as static with a TODO
that requires the developer
to double-check if the query could technically be marked as dynamic (e.g. for simpler
Ivy migration in the future)
If we didn't find any static query usage, the query is still not definitely dynamic, as
the query could be still referenced somewhere else (e.g. dependency injection). In that
case the query timing is dynamic and we just add an inline todo asking the developer to
double-check if the query is used somewhere statically.
For ViewChild
queries, we analyze the template and use the view engine sorting in order
to provide a guaranteed working migration for that view query.
For ContentChild
queries, we can never determine a working/correct query timing with this
strategy and can just leave the decision up to the developer by adding an inline TODO
.
Implementation requirements:
For ViewChild
queries, we use the template selection strategy in order to get a 100% working
migration for these queries.
For ContentChild
queries, we check if the query is statically used. If not, we fallback to the
template selection strategy and just add an inline todo and leave the decision up to the
developer. This allows us to correctly handle the migration for ContentChild
in some cases as
well. Meaning that this strategy has:
The 25%
are determined by estimating that 50%
content queries are statically
used in an application and that the query usage detection has a 50%
migration-rate.
(as it cannot always detect query usage due to various edge-cases)
General todo's
ambigious
case to the usage strategy see @kara's commentor
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing