hexstate 0.32.0

State machine written in Haxe

Released 2017-10-31.

To install, run:

haxelib install hexstate 0.32.0

See using Haxelib in Haxelib documentation for more information.

Maintainerdoclerlabs
Websitehttps://github.com/DoclerLabs/hexState
Current version0.32.0
StatisticsInstalled 578 times
LicenseMIT
Tags

README.md

hexState TravisCI Build Status

State machine written in Haxe

Find more information about hexMachina on hexmachina.org

Dependencies

Simple example

// MessageTypes
this.logAsUser 			= new MessageType( "onLogin" );
this.logAsGuest 		= new MessageType( "onLogAsGuest" );
this.logout 			= new MessageType( "onLogout" );
this.logAsAdministrator = new MessageType( "onLogAsAdministrator" );

// States
this.anonymous 		= new State( "anonymous" );
this.guest 			= new State( "guest" );
this.user 			= new State( "user" );
this.administrator 	= new State( "administrator" );
	
this._stateMachine 	= new StateMachine( this.anonymous );
this._controller 	= new StateController( this._injector, this._stateMachine );

this.anonymous.addEnterCommand( DeleteAllCookiesMockCommand );
this.anonymous.addEnterCommand( DisplayAddBannerMockCommand );
this.anonymous.addTransition( this.logAsUser, this.user );
this.anonymous.addTransition( this.logAsGuest, this.guest );

this.user.addEnterCommand( PrepareUserInfosMockCommand );
this.user.addEnterCommand( DisplayWelcomeMessageMockCommand );
this.user.addExitCommand( StoreUserActivityMockCommand );
this.user.addTransition( this.logAsAdministrator, this.administrator );

this.guest.addEnterCommand( DisplayAddBannerMockCommand );
this.guest.addEnterCommand( InviteForRegisterMockCommand );
this.guest.addTransition( this.logAsUser, this.user );
this.guest.addTransition( this.logout, this.anonymous );

this.administrator.addEnterCommand( GetAdminPrivilegesMockCommand );
this.administrator.addExitCommand( RemoveAdminPrivilegesMockCommand );

this._stateMachine.addResetMessageType( [ this.logout ] );