fsm-spec Pub

A simple Finite State Machine example - implementation

$when:: fsm1.init (id)
   . (dieselScope[="status"]="init")

$when:: fsm1.move
   . (dieselScope[="status"]=((status + "-") + to))

$when:: fsm1.reset
   . (dieselScope[="status"]="")

This works because the context is maintained for the duration of the story. This FSM would not maintain the state across stories, for instance... see below.


TODO i can't persist this because now it won't reset

//$when fsm1.*(id) => ctx.persisted(kind="fsm1", id=id)

TODO implement a better FSM with persistence across stories


Was this useful?    

By: Razie | 2016-06-26 .. 2021-02-02 | Tags: spec , dsl , private


Viewed 722 times ( | History | Print ) this page.

You need to log in to post a comment!

© Copyright DieselApps, 2012-2024, all rights reserved.