Closed niravshah closed 8 years ago
@niravshah do you came with a pattern to handle this?
@niravshah @edwinallenz This slipped past me, sorry for missing it. Machina doesn't explicitly track all the FSMs created, however, there is a newFsm
event you can listen for, so you could do something along these lines if you wanted to keep an object lookup of the FSM instances:
var lookup = {};
machina.on( "newFsm", function( fsm ) {
lookup[ fsm.namespace ] = fsm;
} );
Just bear in mind that not pruning the lookup when you remove instances will most certainly result in memory leaks.
thanks @ifandelse I'll give it a try
My application requires the creation of a large number of FSM and exposing them via a Express API. I am using the Behavioral FSM instance and hence my state machines are stored on individual domain objects. Does the FSM instance maintain a record of all the objects it has initiated?
What would be the suggested way to manage the large number of domain objects initiated with a state machine and get hold of instances to transition them via the Express API?