Skip to content

Commit

Permalink
fix: delete symbol slot after finishing action
Browse files Browse the repository at this point in the history
  • Loading branch information
arlac77 committed Jun 26, 2023
1 parent 22c9eb8 commit 1911ff1
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/statetransition-mixin.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* ongoing transition
*/
Expand All @@ -20,7 +19,7 @@ const TRANSITION_PROMISE = Symbol("transitionPromise");
* @property {number} timeout in milliseconds the transtion is allowed to take
* @property {Transition} initial to begin with
* @property {Transition} during while we are trying to reach the target
* @property {Transition} target
* @property {Transition} target
* @property {Transition} rejected when soemthing goes wrong
*/

Expand Down Expand Up @@ -107,7 +106,6 @@ export function StateTransitionMixin(superclass, actions, initialState) {
* Generated mixin class with support of state transtions.
*/
const clazz = class StateTransitionMixin extends superclass {

#state = initialState;

/**
Expand Down Expand Up @@ -238,7 +236,6 @@ function rejectUnlessResolvedWithin(promise, timeout, name) {
*/
export function defineActionMethods(object, [actions, states]) {
Object.entries(actions).forEach(([actionName, action]) => {
//console.log(action);
const privateActionName = "_" + actionName;

if (!object.hasOwnProperty(privateActionName)) {
Expand All @@ -256,10 +253,8 @@ export function defineActionMethods(object, [actions, states]) {

const t = this[TRANSITION];

if(t) {
if (action.during[t.during]) {
return this[TRANSITION_PROMISE];
}
if (t && action.during[t.during]) {
return this[TRANSITION_PROMISE];
}

// normal start we are in the initial state of the action
Expand Down Expand Up @@ -294,8 +289,8 @@ export function defineActionMethods(object, [actions, states]) {
}

this.state = this[TRANSITION].target;
this[TRANSITION_PROMISE] = undefined;
this[TRANSITION] = undefined;
delete this[TRANSITION_PROMISE];
delete this[TRANSITION];

return this;
},
Expand Down

0 comments on commit 1911ff1

Please sign in to comment.