hexMVC is a powerful MVC+S framework


Keywords
hexmachina, mvc, oop, haxe
License
MIT
Install
haxelib install hexmvc 0.35.0

Documentation

hexMVC TravisCI Build Status

hexMVC is a powerful MVC+S framework

Find more information about hexMachina on hexmachina.org

Dependencies

Features

Module example with service locator

private class MModule extends Module
{
	public function new( serviceLocator : IStatefulConfig )
	{
		super();
		this._addStatefulConfigs( [serviceLocator] );
		this._addStatelessConfigClasses( [MStatelessCommandConfig, MStatelessModelConfig] );
	}
	
	override private function _getRuntimeDependencies() : IRuntimeDependencies
	{
		var rt = new RuntimeDependencies();
		rd.addMappedDependencies( [ new MappingDefinition( IGitService ) ]); 
		return rt;
	}
	
	override public function _onInitialisation() : Void 
	{
		this._dispatchPrivateMessage( MessageTypeList.TEST, new Request( [new ExecutionPayload( something, ISomething )] ) );
	}
}

Model config

private class MStatelessModelConfig extends StatelessModelConfig
{
	override public function configure() : Void 
	{
		this.map( IMModel, MModel  );
	}
}

Stateful command config

private class MStatefulCommandConfig extends StatefulCommandConfig
{
	public function new()
	{
		super();
	}
	
	override public function configure( injector : IDependencyInjector ) : Void
	{
		super.configure( injector );
		this.map( MessageTypeList.TEST, TestCommand ).once().withGuard( MyGuardClass ).withCompleteHandler( function( e : AsyncCommandEvent ){ trace( e ); } );
	}
}

Asynchronous command example with injections

private class TestCommand extends AsyncCommand implements IAsyncStatelessServiceListener
{
	@Inject
    public var model : IMModel;
	
	@Inject
    public var service : IGitService;

    override public function execute( ?request : Request ) : Void
    {
		this.service.addListener( this );
		this.service.call();
    }
	
	public function onServiceTimeout( service : IAsyncStatelessService ) : Void 
	{
		this._handleFail();
	}
	
	public function onServiceComplete( service : IAsyncStatelessService ) : Void  
	{
		this.model.setValue( service.getResult() );
		this._handleComplete();
	}
	
	public function onServiceFail( service : IAsyncStatelessService ) : Void 
	{
		this._handleFail();
	}
	
	public function onServiceCancel( service : IAsyncStatelessService ) : Void  
	{
		this._handleCancel();
	}
}