Comparing version 1.1.4 to 1.1.5
@@ -0,4 +1,6 @@ | ||
/// <reference types="node" /> | ||
import * as fields from '../fields'; | ||
import * as states from '../states'; | ||
import { StateMachine } from '../StateMachine'; | ||
import { EventEmitter } from 'events'; | ||
/** | ||
@@ -8,2 +10,5 @@ * @todo: Implement abstract missing generator methods: Parallel etc. | ||
export declare abstract class AbstractGenerator { | ||
protected emitter: EventEmitter; | ||
constructor(); | ||
on(eventName: string, listener: (target: (fields.Field<any> | states.State)) => void): void; | ||
abstract generateStateMachine(stateMachine: StateMachine): Object; | ||
@@ -10,0 +15,0 @@ abstract generateNextField(field: fields.NextField<any>): Object; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var events_1 = require("events"); | ||
/** | ||
@@ -8,3 +9,7 @@ * @todo: Implement abstract missing generator methods: Parallel etc. | ||
function AbstractGenerator() { | ||
this.emitter = new events_1.EventEmitter(); | ||
} | ||
AbstractGenerator.prototype.on = function (eventName, listener) { | ||
this.emitter.on(eventName, listener); | ||
}; | ||
AbstractGenerator.prototype.getMethodTarget = function (target) { | ||
@@ -21,3 +26,6 @@ var methodTarget = "generate" + target.constructor.name; | ||
AbstractGenerator.prototype.generateField = function (field) { | ||
return this.getMethodTarget(field).call(this, field); | ||
this.emitter.emit("before::generate::field::" + field.constructor.name, field); | ||
var res = this.getMethodTarget(field).call(this, field); | ||
this.emitter.emit("after::generate::field::" + field.constructor.name, field); | ||
return res; | ||
}; | ||
@@ -24,0 +32,0 @@ return AbstractGenerator; |
@@ -224,2 +224,3 @@ "use strict"; | ||
var _this = this; | ||
this.emitter.emit("before::generate::state::" + state.constructor.name, state); | ||
var data = this.getMethodTarget(state).call(this, state); | ||
@@ -230,3 +231,3 @@ var validationErrors = state.validate(); | ||
} | ||
return state.getFields() | ||
var res = state.getFields() | ||
.filter(function (field) { return field.isConfigured(); }) | ||
@@ -236,2 +237,4 @@ .reduce(function (result, field) { | ||
}, data); | ||
this.emitter.emit("after::generate::state::" + state.constructor.name, state); | ||
return res; | ||
}; | ||
@@ -238,0 +241,0 @@ return StepFunctionsGenerator; |
{ | ||
"name": "flowbject", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "Flowbject is a library that allows you to describe state machines with objects.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
157783
3960