tribe
Version:
Tribe is a platform for building rich, powerful, highly scalable distributed HTML5 web and mobile systems.
29 lines (24 loc) • 1.04 kB
JavaScript
module.exports = function (api) {
var facet = require('tribe.pubsub/facet');
facet.prototype.isDistributed = function () {
this.metadata.isDistributed = true;
};
facet.prototype.requires = function (path) {
if (path.charAt(0) !== '/')
path = '/' + path;
// this is not ideal...
if (this.scope)
// if we've got an id, we're creating a real facet and we have previously created dependencies for this facet, just return it
return this.dependencies[path];
else {
// if we don't have an id, we're simply capturing the facet's metadata. store the dependency path and return an "empty" facet
this.metadata.dependencies = this.metadata.dependencies || [];
this.metadata.dependencies.push(path);
return api.create(this.pubsub, path).instance;
}
};
facet.prototype.release = function () {
this.pubsub.releaseFacet(this);
this.end();
};
}