Paul Gschwendtner
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
Static-query migration strategies === There are two ways of how we can migrate existing Angular applications to the new `ViewChild` and `ContentChild` static timing syntax. Either by: 1) Looking at the current usage of the query 2) Inspecting what the query selects in the component template Both approaches have benefits and downsides which are summarized here: **Approach 1 (query usage)** Positives: * Best practices as we don't mark queries as static if they don't need to be (e.g. for Ivy) * Can detect `ContentChild` query timing if used statically (for most cases: see negatives) Negatives: * Limited coverage of application. e.g. queries could be accessed in other parts of the project. e.g. through dependency injection. * These cases can be handled technically but there a lot of edge-cases that need to be handled and this degenerates into a runtime Angular application simulator eventually (e.g. template component scope, virtual injector tree) * e.g. Testing code accessed the query before running `fixture.detectChanges` * Lots of code needed for detection of query usage through TypeScript AST and type checking. **Approach 2 (template selection)** Positives: * Guaranteed to determine *working* timing for `ViewQuery` due to the template analysis. * Easy to implement. Less code needed as template AST can be visited and used to determine query timing Negatives: * Difficult to determine query timing for `ContentChild` since projected content can be inserted from anywhere: * This could technically be handled, but in order to handle that we need to analyze *all* other components that project content into the given component. This is nearly impossible as other Angular projects, which are not statically analyzable, can also project content into the component. Therefore the prediction is never 100% correct. * The Angular compiler can only time the content queries properly at runtime when the projected content and the component hierarchy is already known. * Due to queries marked too aggressively, it makes the template inflexible to future changes. --- ### Usage strategy We 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. ### Template selection strategy 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**: * Need to handle queries that select component/directives instead of template references. * Requires us to determine selectors of specified component/directives identifiers. * Requires us to work with third-party modules through metadata files. ### Mixed strategy 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: * 100% validity and 100% migration-rate for view queries * 100% validity and ~25% migration-rate for content queries :::info 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** * Consider adding another `ambigious` case to the usage strategy [see @kara's comment](https://github.com/angular/angular/pull/29663#discussion_r272755654)

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

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.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully