DEV: adds teardownComponent hook to connector class (#8171)

This is the counterpart to setupComponent and allows you to clean any observers or state when the component is destroyed.
This commit is contained in:
Joffrey JAFFEUX 2019-10-09 00:26:33 +02:00 committed by GitHub
parent 061b98bc75
commit 49a4b0dd9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -16,6 +16,13 @@ export default Ember.Component.extend({
this.set("actions", connectorClass.actions);
},
willDestroyElement() {
this._super(...arguments);
const connectorClass = this.get("connector.connectorClass");
connectorClass.teardownComponent.call(this, this);
},
@observes("args")
_argsChanged() {
const args = this.args || {};

View File

@ -17,7 +17,8 @@ export function extraConnectorClass(name, obj) {
const DefaultConnectorClass = {
actions: {},
shouldRender: () => true,
setupComponent() {}
setupComponent() {},
teardownComponent() {}
};
function findOutlets(collection, callback) {