Closed
Description
Currently we generate one setter registration per bind
value. For example, this annotation:
'bind': {'text': 'tool-tip'}
attached to two classes, A
and B
would generate
registerSetters({'text': (A obj, String value) => obj.text = value})
registerSetters({'text': (B obj, String value) => obj.text = value})
Instead we need to generate a single setter registration using a common parent class of A
and B
. This would be tough to do without resolving in our transformer, which we would like to avoid. As a first approximation, we can omit the parameter type (A
and B
above) which will be interpreted as dynamic
.
To do this, we need global knowledge of the setters which would be registered.
- Modify the
bind_generator
transformer, its primary inputs are the.ngDeps.dart
files generated by the app entry points. - Parse these files, gathering information on the setters to be generated.
- Also parse all
.ngDeps.dart
files imported by the primary inputs. - Where there are multiple setters for a single property, remove type information from the registered setter.
- Output a
.ngSetters.dart
file with asetupReflection
method that registers all setters. - Generate code to import and call
setupReflection
during app setup.