Repository navigation
Generate fast change detector classes in Dart code - #1932
Conversation
|
+1 for reusing the existing code template of JitChangeDetector! |
f2df53a to
167e022
Compare
|
Whoops, I updated this before seeing you comment to diverge from the pattern in the js change detection, but I'd like to lobby for switching the Js code to a more consolidated template also. What do you think @vsavkin ? |
There was a problem hiding this comment.
I'm particularly curious if this change to looseIdentical maintains the intended behavior.
219f2cb to
2a72195
Compare
There was a problem hiding this comment.
Looks like using looseIdentical inside an eval isn't going to work, which makes sense so I reverted the previous change.
However, I think the original line is equivalent to newValue !== oldValue:
For all values a, a === a is true unless isNaN(a)
So (newValue !== newValue) && (oldValue !== oldValue) is equivalent to isNaN(newValue) && isNaN(oldValue), however
isNaN(newValue) && isNaN(oldValue) implies (newValue !== oldValue)
There was a problem hiding this comment.
(newValue !== newValue) && (oldValue !== oldValue)is equivalent toisNaN(newValue) && isNaN(oldValue)
This is not exactly true, because (the global) isNaN() will try to convert the input to number first; e.g.:
isNaN('123') === false, but isNaN('foo') === true.
This will be true for ES6's Number.isNaN(); e.g. (newValue !== newValue) <=> Number.isNaN(newValue) === true
Not that it makes any difference here :) Just saying...
Without having any idea what this code does, I wonder if the previous versions intention was:
// If `newValue` is different than `oldValue` (in terms of !==) AND not both are `NaN`
if (${newValue} !== ${oldValue} && !((${newValue} !== ${newValue}) && (${oldValue} !== ${oldValue}))) {(If that is the case, then if (${newValue} !== ${oldValue}) { is not a propser fix :))
There was a problem hiding this comment.
I am not sure why it is there, and there is no unit test checking this behavior. Let's remove it.
ae34cf4 to
01a0e64
Compare
|
Did you figure out a strategy of testing generated detectors? We need to be sure that our change detection system are in sync. |
|
Did you have thoughts on the code layout in Re: testing, what I'm currently thinking is:
What do you think? |
This sounds good. Can you do it for just one simple test? So we can review it asap? |
ec50cba to
86affb1
Compare
|
Just pushed updates to the If you're okay with it, I'd like to get this checked in before starting to integrate the unit tests. Since the Dart change detectors aren't actually being used anywhere yet it shouldn't cause any problems, and the refactoring to integrate the two feels like it should be a separate commit to me. |
|
We should probably use Are there updates that need to be made to this PR or will edits in |
f454361 to
b1c5305
Compare
There was a problem hiding this comment.
This is all generated using values from simple_watch_config.json by executing pub run gen_change_detectors.dart <path_to_simple_watch_config.json>.
Ideally we would not check this in, but it would be generated by gulp.
|
The actual change detector classes are being generated manually via a tool and the We can either try to automate generating the change detector classes or we can manually re-generate and check them in whenever the change detector tests are updated. I don't particularly like either option, but of them I'd vote for manually running -- automating this seems like it could get a little too clever. |
b1c5305 to
58b6dfa
Compare
|
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. |
|
ACK for the clang-format @vsavkin and I just discussed this and our plan for landing is
This requires the least amount of magic and should allow anybody not updating the |
69e3ce8 to
c1036ae
Compare
|
I spoke with @vsavkin to get a bit more context and we agreed that it would be good to make the following changes:
|
|
Okay, after discussing with @IgorMinar and @vsavkin this morning, here is the approach I'm thinking of: Remove test generation via template & the JSON file. Test configuration is stored in a Add a file defining a top-level function for each of In the tests, it will look like: |
384431c to
e4244ec
Compare
|
@vsavkin , @IgorMinar I'm still not auto-generating the change detectors on each build but the test changes are done. Please let me know if you have any issues with the approach. |
There was a problem hiding this comment.
Can you move this into the change detector module?
There was a problem hiding this comment.
Ah, good catch - this is no longer needed. I'll remove it.
|
I looked through the PR, the test changes look good to me. We still need to regenerate the detectors within the build. I'm not an expert on dart generators so I skipped that part. I noticed that the expression definition is now in the TS file. how do you plan to extract the generators from there? |
5d880ef to
7ea6f8c
Compare
|
@IgorMinar , @vsavkin , the change detector build is now integrated into PTAL |
5773caf to
b17aab2
Compare
|
the gulp related bits lgtm. we'll clean it up more as we cleanup the gulpfile but this is good enough for now. thanks! |
b902195 to
b3f8d76
Compare
|
fyi, I have @IgorMinar signing off on 35f0ee5 introduced an issue that was causing transformer tests to fail -- fixing now & i'll submit once Travis is happy. |
Use the `ProtoViewDto` created by the render `Compiler` to create a `ChangeDetectorDefinition`. From there, generate a subclass of `AbstractChangeDetector` for each `ChangeDetectorDefinition`. Run some basic unit tests for the dynamic and JIT change detectors on pre-generated change detectors.
3159c7b to
000a8e2
Compare
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
/cc @tbosch
I haven't addressed unit tests yet, but wanted to get this to you early in case you have cleanup suggestions for me.
Thanks!