@@ -74,10 +74,11 @@ class _CodegenState {
7474 final List <ProtoRecord > _records;
7575 final List <DirectiveRecord > _directiveRecords;
7676 final CodegenNameUtil _names;
77+ final bool _generateCheckNoChanges;
7778
7879 _CodegenState ._(this ._changeDetectorDefId, this ._contextTypeName,
7980 this ._changeDetectorTypeName, String changeDetectionStrategy,
80- List <ProtoRecord > records, List <DirectiveRecord > directiveRecords)
81+ List <ProtoRecord > records, List <DirectiveRecord > directiveRecords, this ._generateCheckNoChanges )
8182 : _records = records,
8283 _directiveRecords = directiveRecords,
8384 _names = new CodegenNameUtil (records, directiveRecords, '_' , _UTIL ),
@@ -91,7 +92,7 @@ class _CodegenState {
9192 .forEach ((rec) => protoRecords.add (rec, def.variableNames));
9293 var records = coalesce (protoRecords.records);
9394 return new _CodegenState ._(def.id, typeName, changeDetectorTypeName,
94- def.strategy, records, def.directiveRecords);
95+ def.strategy, records, def.directiveRecords, def.generateCheckNoChanges );
9596 }
9697
9798 void _writeToBuf (StringBuffer buf) {
@@ -138,6 +139,8 @@ class _CodegenState {
138139 $_ALREADY_CHECKED_ACCESSOR = true;
139140 }
140141
142+ ${_genCheckNoChanges ()}
143+
141144 void callOnAllChangesDone() {
142145 ${_getCallOnAllChangesDoneBody ()}
143146 }
@@ -393,12 +396,24 @@ class _CodegenState {
393396 }
394397
395398 String _genThrowOnChangeCheck (String oldValue, String newValue) {
396- return '''
397- if(throwOnChange) {
398- $_UTIL .throwOnChange(
399- $_CURRENT_PROTO , $_UTIL .simpleChange(${oldValue }, ${newValue }));
400- }
401- ''' ;
399+ if (this ._generateCheckNoChanges) {
400+ return '''
401+ if(throwOnChange) {
402+ $_UTIL .throwOnChange(
403+ $_CURRENT_PROTO , $_UTIL .simpleChange(${oldValue }, ${newValue }));
404+ }
405+ ''' ;
406+ } else {
407+ return "" ;
408+ }
409+ }
410+
411+ String _genCheckNoChanges () {
412+ if (this ._generateCheckNoChanges) {
413+ return 'void checkNoChanges() { this.runDetectChanges(true); }' ;
414+ } else {
415+ return '' ;
416+ }
402417 }
403418
404419 String _genAddToChanges (ProtoRecord r) {
0 commit comments