meteor-angular2-accounts-material-ui
Version:
Material accounts UI for angular2 and meteor
38 lines (37 loc) • 1.31 kB
JavaScript
var meteor_1 = require('meteor/meteor');
var InjectUserAnnotation = (function () {
function InjectUserAnnotation(propName) {
if (propName === void 0) { propName = 'user'; }
this.propName = propName;
}
return InjectUserAnnotation;
}());
function InjectUser(propName) {
var annInstance = new InjectUserAnnotation(propName);
var TYPE_DECORATOR = function TypeDecorator(cls) {
var propName = annInstance.propName;
var fieldName = "_" + propName;
var injected = fieldName + "Injected";
Object.defineProperty(cls.prototype, propName, {
get: function () {
var _this = this;
if (!this[injected]) {
this[fieldName] = meteor_1.Meteor.user();
if (this.autorun) {
this.autorun(function () {
_this[fieldName] = meteor_1.Meteor.user();
}, true);
}
this[injected] = true;
}
return this[fieldName];
},
enumerable: true,
configurable: false
});
return cls;
};
return TYPE_DECORATOR;
}
exports.InjectUser = InjectUser;
;