Deprecate willDestroy() and isDestroy(ing|ed)#212
Merged
chriskrycho merged 1 commit intomasterfrom Mar 21, 2022
Merged
Conversation
With the availability of the `@ember/destroyables` API, we no longer
need these to be handled via lifecycle hooks. Users previously set up
their own `willDestroy` hook, and it got called for them:
import Modifier from 'ember-modifier';
class MyModifier extends Modifier {
willDestroy() {
// ...
}
}
Now, like with other classes in modern Ember/Glimmer, this can stop
being a "lifecycle hook" and simply use the `registerDestructor` API:
import Modifier from 'ember-modifier';
import { registerDestructor } from '@ember/destroyable';
class MyModifier extends Modifier {
constructor(owner, args) {
super(owner, args);
registerDestructor(this, () => {
// ...
});
}
}
Similarly, instead of checking the `.isDestroyed` or `.isDestroying`
properties on the instance, users can import the correspondingly-named
functions from `@ember/destroyables`, e.g. `isDestroyed(instance)`.
rwjblue
approved these changes
Mar 21, 2022
Comment on lines
+65
to
+66
| deprecateForDestroyables('isDestroying', this); | ||
| deprecateForDestroyables('isDestroyed', this); |
Member
There was a problem hiding this comment.
I think it's very very unlikely that someone overrides the isDestroying/isDestroyed part.
Contributor
Author
There was a problem hiding this comment.
Yeah, I assume the same, but if someone can override those things... 😅
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With the availability of the
@ember/destroyablesAPI, we no longer need these to be handled via lifecycle hooks. Users previously set up their ownwillDestroyhook, and it got called for them:Now, like with other classes in modern Ember/Glimmer, this can stop being a "lifecycle hook" and simply use the
registerDestructorAPI:Similarly, instead of checking the
.isDestroyedor.isDestroyingproperties on the instance, users can import the correspondingly-named functions from@ember/destroyables, e.g.isDestroyed(instance).