Last active
August 29, 2015 13:57
-
-
Save giuseppeg/9638666 to your computer and use it in GitHub Desktop.
a FlightJS mixin to teardown a group of components
This file contains 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
define(function (require) { | |
var registry = require('flight/lib/registry'); | |
return withTeardownColletion; | |
function withTeardownCollection() { | |
this.before('teardown', function () { | |
if (typeof this.attr.collectionName == 'string') { | |
Object.keys(registry.allInstances).forEach(function (instanceKey) { | |
var component = registry.allInstances[instanceKey].instance; | |
if ( | |
/* component !== this && ?*/ | |
component.attr.collectionName && | |
component.attr.collectionName == this.attr.collectionName | |
) { | |
component.teardown(); | |
} | |
}, this); | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment