Comparing version 2.0.3 to 2.0.4
42
index.js
@@ -27,3 +27,3 @@ 'use strict' | ||
this.id = id | ||
this.actualState = initState | ||
this.currentState = initState | ||
this.middlewares = [] | ||
@@ -101,5 +101,5 @@ this.internalEmitter = emitter | ||
return new Promise((resolve, reject) => { | ||
if (instance.actualState.transitions) { | ||
instance.actualState.transitions.forEach((transition) => { | ||
if (Utils.matchRule(transition.name, transitionName) || Utils.matchRegExp(transition.name, transitionName)) { | ||
if (instance.currentState.transitions) { | ||
instance.currentState.transitions.forEach((transition) => { | ||
if (Utils.matchRule(transition.when, transitionName) || Utils.matchRegExp(transition.when, transitionName)) { | ||
return resolve(transition) | ||
@@ -121,4 +121,4 @@ } | ||
if (transition.use) { | ||
instance.middlewares[transition.use](instance.actualState, (data) => { | ||
instance.actualState = nextState | ||
instance.middlewares[transition.use](instance.currentState, (data) => { | ||
instance.currentState = nextState | ||
@@ -129,12 +129,12 @@ client.set(instance.id, instance, this.model.ttl, (err) => { | ||
} | ||
if (instance.actualState.onEnter) { | ||
if (instance.actualState.onEnter.emit) { | ||
instance.internalEmitter.emit(instance.actualState.onEnter.emit, instance.actualState.onEnter.data) | ||
if (instance.currentState.onEnter) { | ||
if (instance.currentState.onEnter.emit) { | ||
instance.internalEmitter.emit(instance.currentState.onEnter.emit, instance.currentState.onEnter.data) | ||
} | ||
} | ||
resolve(instance.actualState) | ||
resolve(instance.currentState) | ||
}) | ||
}) | ||
} else { | ||
instance.actualState = nextState | ||
instance.currentState = nextState | ||
client.set(instance.id, instance, this.model.ttl, (err) => { | ||
@@ -145,8 +145,8 @@ console.log('EL NUEVO ESTADO ' + JSON.stringify(instance)) | ||
} | ||
if (instance.actualState.onEnter) { | ||
if (instance.actualState.onEnter.emit) { | ||
instance.internalEmitter.emit(instance.actualState.onEnter.emit, instance.actualState.onEnter.data) | ||
if (instance.currentState.onEnter) { | ||
if (instance.currentState.onEnter.emit) { | ||
instance.internalEmitter.emit(instance.currentState.onEnter.emit, instance.currentState.onEnter.data) | ||
} | ||
} | ||
resolve(instance.actualState) | ||
resolve(instance.currentState) | ||
}) | ||
@@ -158,3 +158,3 @@ | ||
this.searchNextState('default').then((nextState) => { | ||
instance.actualState = nextState | ||
instance.currentState = nextState | ||
client.set(instance.id, instance, this.model.ttl, (err) => { | ||
@@ -164,8 +164,8 @@ if (err) { | ||
} | ||
if (instance.actualState.onEnter) { | ||
if (instance.actualState.onEnter.emit) { | ||
instance.internalEmitter.emit(instance.actualState.onEnter.emit, instance.actualState.onEnter.data) | ||
if (instance.currentState.onEnter) { | ||
if (instance.currentState.onEnter.emit) { | ||
instance.internalEmitter.emit(instance.currentState.onEnter.emit, instance.currentState.onEnter.data) | ||
} | ||
} | ||
resolve(instance.actualState) | ||
resolve(instance.currentState) | ||
}) | ||
@@ -177,3 +177,3 @@ }).catch((err) => { | ||
} else { | ||
return resolve(instance.actualState) | ||
return resolve(instance.currentState) | ||
} | ||
@@ -180,0 +180,0 @@ }) |
{ | ||
"name": "flowx", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "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
10918