joshtynjala / robotlegs-framework-starling

Robotlegs 1.x ported to Starling
MIT License
18 stars 8 forks source link

commandMap injection always errors #1

Closed izzmeifter closed 10 years ago

izzmeifter commented 10 years ago

Is there any working examples using this? I've used RL dozens of times outside of starling as well as s9tpepper's library with success, but when i try to replace it with this library, I always end up with the;

Error: Injector is missing a rule to handle injection into property "event" of object...

error every time I dispatch an event that is mapped to a command if that event has an injection.

ex.

in Context Class: commandMap.mapEvent(SystemEvent.STARTUP_COMPLETE, StartupCommand, SystemEvent);

in Command Class: [Inject] public var event:SystemEvent

Thoughts?

joshtynjala commented 10 years ago

I built joshtynjala/feathers-weather using this library.

Are you using the SWC (linked in the readme) or the source code? If you're using the source code, you need to make sure that the compiler keeps the Robotlegs metadata. Otherwise, it won't know what to inject. Check the build.xml for what metadata you should keep and what the compiler arguments look like. If you use the SWC, the metadata will be included automatically, and it should just work.

izzmeifter commented 10 years ago

Thanks Josh. I'll give that example a go and see If I can spot the issue. And yes, in this case I was using the SWC in the read me.

joshtynjala commented 10 years ago

Any chance that you were testing on iOS? For some reason, I saw errors with injected properties on iOS when I used ipa-app-store. It worked fine with ipa-test-interpreter, so there's something going wrong with the cross-compiling to native code, I guess. I don't remember if I tried ipa-ad-hoc or any of the other lower levels of optimization. I haven't had much time to troubleshoot further.

izzmeifter commented 10 years ago

I believe I was on the larger project, but I think on a separate test I did, I was experiencing the same issues even in the ADL. I'll let you know what I find out. Thanks again.

izzmeifter commented 10 years ago

So I've downloaded the feathers-weather app, and compiled it fine, but found that it doesn't actually inject any events with commandMap, so in trying out a quick test, I experience the same problems. The simplest way to test was to add

this.commandMap.mapEvent(StartupEvent.STARTUP, StartupCommand, StartupEvent);

in the Context and at the end of the startup override just dispatch a standard extended starling Event

var evt:StartupEvent = new StartupEvent(StartupEvent.STARTUP); evt.obj = {name:"Robotlegs"}; this.dispatchEvent(evt)

and in StartupCommand

[Inject] public var event:StartupEvent;

Which results in the Error: Injector is missing a rule to handle injection into property "event" of object "[object StartupCommand]". Target dependency: "feathers.examples.weather.events::StartupEvent", named ""

In the interest of time right now, i'll switch back to s9tpeppers version, but I will definitely revisit this lib as I prefer the execution.

Thanks Josh.

joshtynjala commented 10 years ago

Thanks for the info. I was able to reproduce the issue, and I got it fixed. Conveniently, it appears that my issue on iOS was fixed with it. :smile: