Skip to content
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

feat(compiler): Add implementation for a XHR that uses a template cache to load template files. #7940

Closed
wants to merge 1 commit into from

Conversation

vikerman
Copy link
Contributor

@vikerman vikerman commented Apr 6, 2016

  • Please check if the PR fulfills these requirements
  • The commit message follows our guidelines: https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit-message-format
  • Tests for the changes have been added (for bug fixes / features)
  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
    Feature - Provide a XHR implementation that uses a template cache to avoid actually making an XHR. Exports CACHED_TEMPLATE_PROVIDER through angular2/platform/browser and angular2/platform/testing/browser which can be used by applications and tests to use the cached XHR implementation.
  • What is the current behavior? (You can also link to an open issue here)
    Support preloading of templates, at least for testing #4051
  • What is the new behavior (if this is a feature change)?
    If the application or test uses the cached XHR implementation by setting up the provider for XHR it will use the template cache instead of making an actual XHR. This can be useful for writing fakeAsync tests.
  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
    No
  • Other information:

Useful for avoiding doing an actual XHR during testing.
Part of the solution for #4051 (Other part is a Karma plugin that will create the template cache).

@vikerman
Copy link
Contributor Author

vikerman commented Apr 6, 2016

cc @juliemr

@lacolaco
Copy link
Contributor

lacolaco commented Apr 7, 2016

Is this just for testing?
I want a similar system for application to preload (programmatical load) component's template refered by templateUrl.
It is like ng-template of ng1.

@ericmartinezr
Copy link
Contributor

@laco0416 that's what the new compiller will do, will convert the templateUrl's in files intead of requesting them

@lacolaco
Copy link
Contributor

lacolaco commented Apr 7, 2016

@ericmartinezr sounds good. thx!


constructor() {
super();
this._cache = (<any>window).$templateCache;
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't use window but the global variable exported from angular2/src/facade/lang.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@tbosch tbosch added pr_state: LGTM action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Apr 7, 2016
…che to load template files.

Useful for avoiding doing an actual XHR during testing.
Part of the solution for #4051 (Other part is a Karma plugin that will create the template cache).
@vikerman vikerman added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Apr 8, 2016
@mary-poppins
Copy link

Merging PR #7940 on behalf of @alxhub to branch presubmit-alxhub-pr-7940.

@mhevery mhevery closed this in a596b88 Apr 8, 2016
mircoservices pushed a commit to mircoservices/angular that referenced this pull request Apr 10, 2016
…che to load template files.

Useful for avoiding doing an actual XHR during testing.
Part of the solution for angular#4051 (Other part is a Karma plugin that will create the template cache).

Closes angular#7940
@angular-automatic-lock-bot
Copy link

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 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants