-
Notifications
You must be signed in to change notification settings - Fork 25.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(LifecycleEvent): remove LifecycleEvent #3928
Conversation
/** | ||
* Defines lifecycle method {@link metadata/LifeCycleEvent#OnChanges `LifeCycleEvent.OnChanges`} | ||
* called after all of component's bound properties are updated. | ||
*/ | ||
export interface OnChanges { onChanges(changes: StringMap<string, any>): void; } | ||
export class OnChanges implements LifecycleHook { |
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.
Why did you have to make these into classes?
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.
So that we can write hasLifeCycleHook(OnChanges, MyComponent);
and don't have to maintain a duplicate enum.
68efb5a
to
694ff70
Compare
@kegluneq I would appreciate some help to update the Dart transformers for this PR - I have done some updates but more is needed. The PR is about removing the need for declaring @Component({
// lifecycle: const [LifecycleEvent.OnChanges], -> This config is dropped
...
})
class MyComp implements OnChanges { // -> The code now relies on the interfaces which already are the type info
// ...
}
For item 2 above, the best would be if you could send a PR to my repo: |
375cd46
to
b2aa2b1
Compare
return annotation.lifecycle.contains(e); | ||
} else { | ||
if (type is! Type) return false; | ||
bool hasLifecycleHook(/*LifecycleHook*/ interface, type) { |
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.
What is preventing us from providing types for these parameters?
I don't see any issues with the changes so far, with the exception of your point (2) above, that I would guess that is why the Travis test is failing. I can make the updates to The current implementation expects to be processing either the I think the easiest way to make this update is to have the reader accept, instead of the |
@kegluneq you're right, You would be much more efficient than me to do the updates there. So please take a look whenever you have time. Thanks ! |
/cc @keertip this change required updates to Let me know if you see any issues stemming from this. |
@kegluneq , thanks for the info. Will take a look after this lands. |
7ad45d6
to
f133d39
Compare
7a4e2a7
to
815a0bf
Compare
The last commit triggers a typings error, not sure how to solve this, see https://travis-ci.org/angular/angular/jobs/78499681#L260 |
7edbad7
to
3689bae
Compare
Thanks to @IgorMinar the typings generation issue has been solved. @mhevery could you please review. |
Merging PR #3928 on behalf of @vicb to branch presubmit-vicb-pr-3928. |
Merging PR #3928 on behalf of @vicb to branch presubmit-vicb-pr-3928. |
fixes angular#3924 BREAKING CHANGE The `lifecycle` configuration for directive has been dropped. Before // Dart @component({lifecycle: const [LifecycleEvent.OnChanges], ...}) class MyComponent implements OnChanges { void onChanges() {...} } // Typescript @component({lifecycle: [LifecycleEvent.OnChanges], ...}) class MyComponent implements OnChanges { onChanges(): void {...} } // ES5 var MyComponent = ng. Component({lifecycle: [LifecycleEvent.OnChanges], ...}). Class({ onChanges: function() {...} }); After // Dart @component({...}) class MyComponent implements OnChanges { void onChanges() {...} } // Typescript @component({...}) class MyComponent implements OnChanges { onChanges(): void {...} } // ES5 var MyComponent = ng .Component({...}) .Class({ onChanges: function() { } });
…cle_hooks) BREAKING CHANGE Lifecycle hooks now live in the `angular2/lifecycle_hooks` module. They previously lived in the `metadata` module.
/cc @jeffbcross |
Thanks @yjbanov I've already (painfully) rebased against these changes :) |
@jeffbcross sorry for that, I know how it feels ! - I had to rebase this one >5 times to get it in :( |
Haha @vicb no worries |
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. |
TODO: