The PhaseMachine is quite old, and could benefit from cleanup. In porting it from GEMSTEP into TypeScript, I noticed some problems with it.
[ ] nomenclature between "phases", "phase groups", and "phase operations" is unclear in how they related to the PHASEMAP structure.
[ ] the way that execute() assumes either a group name or a named phase (operation?) inside the group is not very obvious.
[ ] executePhase() is really "execute phase group"
[ ] executePhase() also does not return a Promise. It instead uses an obscure combination of reduce() with Promises to execute the block that works, but not as expected. You have to put an await PM.executePhase('PHASE_NAME') inside an async block, but Typescript doesn't think it's necessary because it doesn't understand what's going on.
[ ] The semantics for PhaseMachine are a bit different than that for GEMSTEP's version of URSYS, so I'd like to resolve that.
[ ] The way of accessing specific PhaseMachine instances through the static methods is unclear, and not addressed in calls like execute() and hook() (maybe they should)?
I'd like to add some formal transition event logic to PhaseMachine too, having it control a small global state object that can be used to set flags. However, there is no current need for it with current projects, so it's not a priority.
The PhaseMachine is quite old, and could benefit from cleanup. In porting it from GEMSTEP into TypeScript, I noticed some problems with it.
execute()
assumes either a group name or a named phase (operation?) inside the group is not very obvious.executePhase()
is really "execute phase group"executePhase()
also does not return a Promise. It instead uses an obscure combination ofreduce()
with Promises to execute the block that works, but not as expected. You have to put anawait PM.executePhase('PHASE_NAME')
inside an async block, but Typescript doesn't think it's necessary because it doesn't understand what's going on.execute()
andhook()
(maybe they should)?I'd like to add some formal transition event logic to PhaseMachine too, having it control a small global state object that can be used to set flags. However, there is no current need for it with current projects, so it's not a priority.