MapSingleton, MapClass of Robotlegs not recognised in Haxe

@singmajesty

Hi

I am stuck at a very crucial point and seems like a dead end for me.
I have got many robotlegs mappings in my as3 code like :

m_context.contextInjector.mapSingleton(abc);
m_context.contextInjector.mapSingleton(xyz);
m_context.contextInjector.mapClass(test, test1);
m_context.contextInjector.mapClass(test2, test3);

contextInjector above returns IInjector.
In as3 everything works fine, but in Haxe i get the following error.

Error : IInjector has no field mapSingleton
Same error for mapClass : IInjector has no field mapClass

Haxe does not recognise mapSingleton, mapClass etc… PLEASE HELP

@singmajesty

Awaiting your kind response at the earliest. Thanks

maybe @mayakwd can give you an answer, I know he uses Robotlegs.

Do you use the last haxe-robotlegs lib?

context.injector.map(ISomething).toSingleton(SomethingImpl);

or

context.injector.map(SomethingImpl).asSingleton();

Robotlegs for haxe based on second version of robotlegs: context.injector.map(...) returns InjectionMapping you could check it’s code with comments.

I recommend you to start reading documentation from here.

1 Like

@mayakwd

Thanks. But now I am getting the same type of error for mapClass, mapView, mapEvent etc.

This is the code :
m_context.contextInjector.mapClass(ClassA, ClassB);

Error :
robotlegs.bender.framework.api.IInjector has no field mapClass

same for mapView, mapEvent etc :
m_context.contextMediatorMap.mapView(View1, Mediator1);
m_context.contextCommandMap.mapEvent(Event1, Command1, Event2);

@mayakwd

Any suggestions… ?

You could use same structure:

imports ...;

class Main {
  private var context:IContext;

  public static function main() {
    _context = new Context()
      .install(MVCSBundle)
      .configure(ApplicationConfig)
      .configure(new ContextView(this));
  }
}

class ApplicationConfig implements IConfig {
  @inject public var mediatorMap:IMediatorMap;
  @inject public var commandMap:IEventCommandMap;

  public function configure() {
    mediatorMap.map(SomeView).toMediator(SomeViewMediatorr);
    commandMap.map(SomeEvent.EVENT_NAME).toCommand(SomeCommand);
  }
}