-
Notifications
You must be signed in to change notification settings - Fork 248
Conversation
I've just added the publishing of NgForm instances on the context /cc @matsko |
Updated to include #1247 |
@@ -52,7 +46,8 @@ class _StaticApplication extends Application { | |||
ngModule | |||
..bind(MetadataExtractor, toValue: new StaticMetadataExtractor(metadata)) | |||
..bind(FieldGetterFactory, toValue: new StaticFieldGetterFactory(fieldGetters)) | |||
..bind(ClosureMap, toValue: new StaticClosureMap(fieldGetters, fieldSetters, symbols)); | |||
..bind(ClosureMap, toFactory: (_) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line doesn't conform to DI 2.0, needs s/(_)/()/. OOC, why is this change necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks. This should be a merge artifact, I'll revert
This is quite a PR, to be able to land in gracefully for internal clients we might need to reorder the features and the commits. Here is my proposed order:
At each step I would sync with clients and make sure there are no breakages. @vicb Is it feasible to create commits in that order with those features, or I am missing some dependency? |
No this is not feasible. I have already rebased this PR several times and I think the order / content of the commits is quite optimal. Find more details below:
There are a few commits with refactoring. They are placed at specified places because they depend on former changes
I don't see a reason to separate those, they are linked.
I've tried to come with something that would allow an easier transition but it would require a lot of code. In think it doesn't make a lot of sense to separate those, the transition is very easy and straightforward.
I have to verify if this can be separated from the two first commits and update if it can not (there might be some issues with former squash / fixup)
This should be grouped with other commits as the first two commits remove the possibility to publish the form in the context that this commit re-add. If they are separated this feature will be disabled until this commit is merged.
Nothing is deprecated by this PR. The probe directive has been deprecated by a former commit. This PR only updates the tests to not use it any more - nothing required for client code.
keeping publishAs would require adding extra code in the parser, not exactly simple. My suggestion would be to merge:
(-> no more publishAs after this chunk) then (I have to check if this is possible yet, if not update)
then (those 3 commits could be merged separately, they do not affect client code)
then
Of course there is some room for discussion but I'd rather write a migration guide and/or help the clients to migrate rather than doing some of your proposed updates (and they would take time and require having to rebase again, ... The original PR, 1040 is dated from May 13). The migration for each of the steps I propose is quite easy and already documented in the commit comments. Let's chat about this tomorrow or Friday. |
@rkirov I've split the first commit in two parts:
Despite what GH prints the order is as above, it is probably related to the commit dates ? Next, I'll:
|
Great, thanks @vicb! I am working on landing rootContextType and removing all Controllers from clients. @jbdeboer brought a valid point that we have no strategy for moving users of scope.context without going through controller, but once I have your commit (and no more Controllers) I can try to estimate the impact. |
closes dart-archive#919 closes dart-archive#917 Backard Compatibility breaks: 1) The @controller has been removed It is possible to define the context of the root scope with: applicationFactory() ..rootContextType(RootContext) ..run(); The root context type needs to be annotated with @Injectable(): @Injectable() class RootContext { // ... } 2) You can not inject a scope in a component or in the root context any more As the Scope context is set to the Component instance, the scope could not be injected any more. Components should implements the "ScopeAware" interface and declare a "scope" setter in order to get a reference to the scope. before: @component(...) class MyComponent { Watch watch; Scope scope; MyComponent(Dependency myDep, Scope scope) { watch = scope.rootScope.watch("expression", (v, p) => ...); } } after: @component(...) class MyComponent implements ScopeAware { Watch watch; MyComponent(Dependency myDep) { // It is an error to add a Scope / RootScope argument to the // ctor and will result in a DI circular dependency error // The scope is never accessible in the class constructor } void set scope(Scope scope) { // This setter gets called to initialize the scope watch = scope.rootScope.watch("expression", (v, p) => ...); } } or: @component(...) class MyComponent implements ScopeAware { Scope scope; MyComponent(Dependency myDep) { // It is an error to add a Scope / RootScope argument to the // ctor and will result in a DI circular dependency error // The scope is never accessible in the class constructor } }
Closes dart-archive#915 1) Now "a.b" return a.b and "a['b']" return a['b'] Before this change a.b would have match either a.b or a['b']. The reason is that the context was a Map (before dart-archive#914) and we don't want to write ctrl['foo'] but ctrl.foo. It was also not possible to access Map properties, ie map.length would have returned map['length']. 2) Accessing probes The probes are no more accessible directly in the rootScope context but in a $probes map on the rootScope context. Before: <p probe="prb"></p> var probe = rootScope.context['prb']; After: <p probe="prb"></p> var probe = rootScope.context.$probes['prb']; 3) Forms As a side effect of this change, the forms are now available in the context field named after the form: @component( selector: 'my-component', template: ''' <form name="myForm"> <input type="text" ng-model="model"> </form> ''' ) class Component { // myForm is automatically initialized to the NgForm instance NgForm myForm; } When the field named after the form is not present, an exception is thrown.
…ILDREN) Backward compatibility breaks: 1- Transclusion syntax has changed: Before: @decorator( selector: '[ng-if]', children: Directive.TRANSCLUDE_CHILDREN, map: const {'.': 'mapping'}, <other kv pairs>) After: @template( selector: '[ng-if]', map: const {'ng-if' : 'mapping'}, <other kv pairs>) 2- Directive.children has been removed in favor of Directive.compileChildren dor Directive.map Before: - children: Directive.COMPILE_CHILDREN - children: Directive.IGNORE_CHILDREN - children: Directive.TRANSCLUDE_CHILDREN After: - compileChildren: true - compileChildren: false - Use @template (see the previous section)
@rkirov I've implemented the changes we've talked about yesterday:
I've published my branch as it was before the changes for when w need to revert the features added in order to ease the migration. |
I moved clients away from Controller and probe directive (they all use ngRoute, so we can even remove the directive altogether). Next step is getting ScopeAware in, so I can more them away from injecting Scope, before landing the 'Drop the Controller directive' commit. Take a look at #1360 for that. Also, while testing clients I noticed that injecting Scope into Components results in infinite recursion (+ stack overflow). Can we detect the infinite loop in the DirectiveInjector and throw a more informative error? |
Great !
@rkirov that's probably something we should do. The directive injector was first not able to detect circular deps, the status is still not clear to me, see #1240 |
@rkirov do you agree with the following plan:
I think we already agreed on 1, 3 & 4. The opened question is about rebasing (2) |
That sounds good, can you LGTM #1364 if you think it is ready to be submitted. |
Completely remove the deprecated Controller directive. Major update to the demos to use setRootContext (where applicable) and to move to Components for the beefier demos (bouncing balls and form). A temporary work around was required in demos (animation and todo) so that rootContext have Map interface. The work arounds will disappear after the context is set to the component. Library changes were pulled out of the first commit in dart-archive#1269.
Completely remove the deprecated Controller directive. Major update to the demos to use setRootContext (where applicable) and to move to Components for the beefier demos (bouncing balls and form). A temporary work around was required in demos (animation and todo) so that rootContext have Map interface. The work arounds will disappear after the context is set to the component. Library changes were pulled out of the first commit in dart-archive#1269.
Completely remove the deprecated Controller directive. Major update to the demos to use setRootContext (where applicable) and to move to Components for the beefier demos (bouncing balls and form). A temporary work around was required in demos (animation and todo) so that rootContext have Map interface. The work arounds will disappear after the context is set to the component. Library changes were pulled out of the first commit in dart-archive#1269.
Completely remove the deprecated Controller directive. Major update to the demos to use setRootContext (where applicable) and to move to Components for the beefier demos (bouncing balls and form). A temporary work around was required in demos (animation and todo) so that rootContext have Map interface. The work arounds will disappear after the context is set to the component. Library changes were pulled out of the first commit in dart-archive#1269.
Completely remove the deprecated Controller directive. Major update to the demos to use setRootContext (where applicable) and to move to Components for the beefier demos (bouncing balls and form). A temporary work around was required in demos (animation and todo) so that rootContext have Map interface. The work arounds will disappear after the context is set to the component. Library changes were pulled out of the first commit in dart-archive#1269.
Completely remove the deprecated Controller directive. Major update to the demos to use setRootContext (where applicable) and to move to Components for the beefier demos (bouncing balls and form). A temporary work around was required in demos (animation and todo) so that rootContext have Map interface. The work arounds will disappear after the context is set to the component. Library changes were pulled out of the first commit in dart-archive#1269.
Completely remove the deprecated Controller directive. Major update to the demos to use setRootContext (where applicable) and to move to Components for the beefier demos (bouncing balls and form). A temporary work around was required in demos (animation and todo) so that rootContext have Map interface. The work arounds will disappear after the context is set to the component. Library changes were pulled out of the first commit in #1269. Closes #1401
Completely remove the deprecated Controller directive. Major update to the demos to use setRootContext (where applicable) and to move to Components for the beefier demos (bouncing balls and form). A temporary work around was required in demos (animation and todo) so that rootContext have Map interface. The work arounds will disappear after the context is set to the component. Library changes were pulled out of the first commit in #1269. Closes #1401
@vicb It's been awhile but things are moving in the right direction. I rebased the bottom two commits and reverted some of the temporary changes I made in examples. Take a look at this branch: There will be a proper PR in a few days (when I convince myself the changes are non-breaking for client if they add ScopeAware and publishAs getters). There were two minor changes I had to make:
I had to replace the local |
This looks wrong to me, I'll take a look at your branch |
Take a look at #1429. I added two tests to dirty_change_detection_spec that were failing before my modification. Basically, if we change local variable |
8fd235c
to
50e2645
Compare
Closing this PR to clean up the queue. We've been importing the work in smaller chunks. @vicb please keep the source around at your end, but we'll create new PRs moving forward. |
This PR supersedes #1040.
This PR contains:
@Controller
annotation,a.b
always evaluate toa.b
instead ofa[b]
),probe
directive (which is deprecated),@Template
replaces@Decorator(Directive.TRANSCLUDE_CHILDREN)
see commit comments for more details