0

I'm using Parsley 3.0 with the Flex extensions, but was wanting to use the spicelib syntax for executing a command group:

        Commands.asSequence()
                .create(LoadCachedCredentialsCommand)
                .create(LoginCommand)
                .lastResult(appInit_resultHandler)
                .error(appInit_errorHandler)
                .execute();

When doing it like this, I've noticed that injection with metadata in the commands do not work. Is this expected behavior? I assumed all the normal functionality with injection when defining the commands in the context would also work in this situation. But I wanted to confirm this to make sure I wasn't simply doing something wrong.

1 Answers1

0

This is expected, as Spicelib itself does not know about Parsley. If you want your sequence to be managed by Parsley, you need to add it manually to the context:

var sequence:Command = Commands.asSequence()
                               .create(LoadCachedCredentialsCommand)
                               .create(LoginCommand)
                               .lastResult(appInit_resultHandler)
                               .error(appInit_errorHandler)
                               .execute();
var context:Context = ...;          
ManagedCommands.wrap(sequence)
               .execute(context);

See also here in the Parsley documentation.

dvdgsng
  • 1,691
  • 16
  • 27
  • Thank you. I did eventually find the same solution in the manual. Since then, I've discovered that, using this method, constructor injection, via InjectConstructor, does not work. It fails find a matching type of managed object. But property injection works fine. I guess, maybe, it's a bug... but something not difficult to work around. – user3204406 Jan 18 '14 at 18:17