hexstate 0.17.0

State machine written in Haxe

Released 2017-03-20.

To install, run:

haxelib install hexstate 0.17.0

See using Haxelib in Haxelib documentation for more information.

This is not the latest stable version of hexstate. See version 0.18.0 for the latest version.

Maintainerdoclerlabs
Websitehttps://github.com/DoclerLabs/hexState
Current version0.18.0
StatisticsInstalled 416 times
LicenseMIT
Tags hexmachina, mvc, oop

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 ] );