ngrx-vis
Version:
<p align="center"> <img src="https://github.com/co-IT/ngrx-vis/blob/master/assets/logo.png?raw=true"> </p>
38 lines (37 loc) • 1.74 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var path_1 = require("path");
var ts_morph_1 = require("ts-morph");
var ngrx_1 = require("../utils/ngrx");
var EffectDispatcherRule = /** @class */ (function () {
function EffectDispatcherRule() {
}
EffectDispatcherRule.prototype.canExecute = function (actionReference) {
var effectDeclaration = actionReference
.getNode()
.getFirstAncestorByKind(ts_morph_1.SyntaxKind.PropertyDeclaration);
return !effectDeclaration || this.isDispatchDisabled(effectDeclaration)
? false
: ngrx_1.extractAllActionTypes(effectDeclaration).some(function (actionType) {
return actionType === ngrx_1.extractActionType(actionReference.getNode());
});
};
EffectDispatcherRule.prototype.execute = function (actionReference) {
var effectDeclaration = actionReference
.getNode()
.getFirstAncestorByKind(ts_morph_1.SyntaxKind.PropertyDeclaration);
var propertyName = effectDeclaration === null || effectDeclaration === void 0 ? void 0 : effectDeclaration.getName();
var fileName = path_1.basename(actionReference.getSourceFile().getFilePath());
return {
caption: propertyName + "\\n" + fileName,
fileName: fileName,
filePath: actionReference.getSourceFile().getFilePath(),
category: 'effect'
};
};
EffectDispatcherRule.prototype.isDispatchDisabled = function (effectDeclaration) {
return effectDeclaration.getText().includes('{ dispatch: false }');
};
return EffectDispatcherRule;
}());
exports.EffectDispatcherRule = EffectDispatcherRule;