2

I'm using ExtJS and think it's an amazing framework. However, they don't have a statechart built in which makes app development depending on states very painful.

I recently found this one:

https://github.com/jakesgordon/javascript-state-machine

It seems like a very solid statechart for JS applications.

I wonder if there are other frameworks like this so that I can compare before I settle with which to use.

Thanks!

ajsie
  • 77,632
  • 106
  • 276
  • 381

4 Answers4

11

Things like JS Statemachine are fundamentally different than Statecharts. They are really a superset of FSM. If you are doing a sproutcore-based application, the native Statecharts are good (a little verbose imho). If you are using another framework or rolling your own javascript, Stativus is really the only full featured statechart framework out there. Stativus can be used in any javascript framework: Backbone.js, ember.js, SproutCore, batman.js, ExtJS, Sencha etc...

With FSM, you don't get:

  • Parallel States
  • Nested Substates
  • History States
  • Statechart Event Propagation

Its really like trying to drag race a Yugo with a Ferrari. They both can get you places and have four wheels, but one has so much more power that it isn't even a competition.

caveat: I helped write the original statechart implementation for SproutCore and I wrote Stativus...

etgryphon
  • 166
  • 1
  • 5
  • Thanks for this, stativ.us looks promising, although, still very much in alpha (docs and site seems buggy). While it is true that a state chart is an extension of FSM, it not that different, and if all you require is four wheels to get from A to B without the pomp.. then JS Statemachine is a useful pragmatic solution. – Nigel_V_Thomas May 28 '12 at 08:09
  • 2
    I'm just getting to the site and documentation. The underlying code is pretty solid and is being used in a couple of production sites. If you find bugs, please tell me... – etgryphon May 31 '12 at 11:42
  • The lack of Stativus documentation is really holding back adoption IMHO. –  May 11 '14 at 03:49
2

Another Statechart implementation in JavaScript is statechart by David Durman.

one more: Machine.js, based on "behavior trees". http://machinejs.maryrosecook.com/

New one: xstate, https://github.com/davidkpiano/xstate

Josef.B
  • 942
  • 8
  • 16
1

I'm using javascript-state-machine, and liking it quite a lot. The only gotcha I came across is trying to use the Asynchronous State Transitions. Be sure to use them on entering or leaving states. Not before or after events. With that, everything is working well. A solid tool so far.

Nutritioustim
  • 2,686
  • 4
  • 32
  • 57
0

I like Javascript Finite State Machine (v2.0.0) as well.

A few others I have not tried:

Which one did you settle for?

Domi
  • 553
  • 4
  • 6
Nigel_V_Thomas
  • 907
  • 13
  • 27
  • I settled with all of them :) SproutCore Blossom is using Ki (which is the same as SproutCore's statechart). There is a chance they will use Stativus instead under the hood in the future. – ajsie Mar 04 '12 at 22:10