Samsung Smart TV Development with HaXe and MVC

haxemvc

Next step with my project was to implement MVC framework. The most popular one called mmvc provided by massive interactive seemed a bit broken when used with HaXe 3 RC, but as all those sources are available, I managed to do some small updates in order to compile it without errors. Normaly you would just install the mmvc library using haxelib and the install process grabs the necessary dependencies like msignal, minject, mcover, mcore… But in order to fix HaXe 3 issues, I decided to just download it into my projects src folder.

mmvc reuse a lot of patterns and naming conventions from RobotLegs framework I believe all ActionScript 3 developers are familiar with already. However, events has been completely replaced by signals. Signals are as well rewritten from its ActionScript brother. You can also benefit from dependency injections using HaXe metadata.

Once I got rid of compilation errors regarding HaXe 3 compiler changes, everything ran smooth out of the box for my JavaScript project on emulator as well as on TV device. One thing that was not that obvious was signal mapping within context, e.g. if you map signal into a command

commandMap.mapSignalClass(DemoSignal, DemoSignalCommand);

Then you have to make sure you use the injected DemoSignal instance in your mediator:

class MainViewMediator extends Mediator<MainView>
{
	@inject
	public var demoSignal:DemoSignal;
	
	override function onRegister()
	{
		super.onRegister();
		
		//demoSignal.completed.add(onSignalCompleted);
		demoSignal.dispatch();
	}
}

It is also suggested to have a completed property-signal in your signal class in order to get notified once the command has executed the signal. I guess this may result in some issues in case you reuse the signal in multiple mediators.

There is an example project provided with mmvc repository that will help you get started. You can find my project sources including updated mmvc sources in the repository. Make sure to checkout for latest changes from original repos.

Where to go from here:

  • mmvc – HaXe IOC framework utilizing Signals and macro based injectionk
  • msignal – HaXe port of the ActionScript 3 Signals library that leverages Haxe type parameters.
  • minject – HaXe port of the ActionScript 3 SwiftSuspenders IOC library with efficient macro enhanced type reflection
  • RobotLegs – an ActionScript Application Framework. It offers: Dependency, Module, Command and View management.
  • Signals – ActioScript approach for AS3 events, inspired by C# events and signals/slots in Qt

Leave a comment

Please be polite and on topic. Your e-mail will never be published.