More Javascript statechart frameworks

倾然丶 夕夏残阳落幕 提交于 2019-12-03 22:17:06
Nigel_V_Thomas

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

A few others I have not tried:

Which one did you settle for?

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...

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!