Skip to content

Change detector integrate - #2077

Closed
kegluneq wants to merge 17 commits into
angular:masterfrom
kegluneq:change_detector_integrate
Closed

kegluneq wants to merge 17 commits into
angular:masterfrom
kegluneq:change_detector_integrate

Conversation

@kegluneq

Copy link
Copy Markdown

This is a piece of hard-coded hackery, but it gets generated ChangeDetector classes running in hello_world!

Getting this to work brought up a few issues:

  1. Can we use preGeneratedProtoDetectors for testing purposes rather than allowing another map to be passed in?
  2. I'd like to replace preGeneratedProtoDetectors with a thin object that gives some API related to registering ProtoChangeDetectors.
  3. We need to sync up our methods of creating ChangeDetectorDefinition ids. I'm setting just using the type name in ViewDefinitionCreator, which matches the id being passed in for change detection, but these could collide. We should update to something a bit more unique and share code.
  4. What is the difference between HelloCmp_host_0 and HelloCmp_comp_0? Are we supposed to be pre-generating a ChangeDetector for HelloCmp_host_0?

Tim Blasi added 17 commits May 21, 2015 12:36
Use the `ProtoViewDto` created by the render `Compiler` to create a
`ChangeDetectorDefinition`.
Use the `ChangeDetectorDefinition` object to codegen subclasses of
`AbstractChangeDetector` for each `Component`.
- Use looseIdentical
- Use DIRECTIVES_ACCESSOR
Use gulp-template to generate tests from a configuration file.

In the future, the config file can be used to generate Dart
`ChangeDetector` classes so we can use the same code for testing
Dynamic, Jit, and pre-generated implementations of change detection.
Comment thread gulpfile.js

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if you do it this way, developers will not be able to iterate on the test without a full rebuild. in other words, this will cause issues for all test.unit.* tasks. A better way would be to integrate this into the broccoli pipeline, but before we do that I'd like to know for sure that generating the test file is really the only way to do this.

It looks pretty insane and unreadable to me.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm open to other ideas - some more background (sorry if this is all old news):

Js creates ChangeDetector classes on the fly with new Function, but Dart's security policy doesn't allow arbitrary code execution so we need to generate those ahead of time.

Each feature we want to test in a template dictates a change in the structure of the associated ChangeDetector, so our options here are:

  1. Conflate a bunch of tests into a single change detector class
  2. Have a separate change detector class for each test case

Each has their challenges, and option 2 is what the existing change detectors use so I didn't see a compelling reason to switch.

Generating those classes requires an instance of ChangeDetectorDescription, so the *.config.json file is the minimum amount of information necessary to create one. I'm running a tool against that file to generate the classes in Dart, and my thought is to check those in to a generated/ directory. build.js.test/change_detectors uses that information and the *.jstemplate file to create the Js test file, but an alternative is to pre-generate and check this in as well. That might make things a little more "sane", but it also means every change will require a manual step to re-generate the tests. On top of that, everything will silently pass if you forget to manually regenerate, which is not the case if we automatically regenerate one or the other.

What do you think? Any ideas for simplifying?

@tbosch

tbosch commented May 22, 2015

Copy link
Copy Markdown
Contributor

FYI, we will update clang-format to a new version today (see #2059). So before this PR gets rebaed ontop of master, please do a local clang-format with the newest clang-format locally to minimize merge conflicts.

@kegluneq

Copy link
Copy Markdown
Author

This served its purpose of discussion, closing now to focus on #1932

@angular-automatic-lock-bot

Copy link
Copy Markdown

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants