Closed mscharp closed 9 years ago
Hi, The result you get from the dispatch call is the expected result. You are executing just one command, but in commangular when you dispatch and event you can execute a command chain with decision points and other features, so the response from the dispatch can't be the result from just one command.
In a normal commangular application even you don't need to capture the result from the dispatch. You should use the onResult method inside the command to get the result from the promise resolved. If you need to execute something after all the command chain you can use event aspect "@After" and inject any of the result keys from any command executed in the chain. if some result key was a promise, the result resolved will be injected
Thank you for the quick response! That makes perfect sense as to why it's not the resolved promise.
The reason I'm capturing the result is because I need the result from the async call in the context from which the dispatch was made.
If you need to do it like that, then read the command result from the commandModel property using the result key. Al the results resolved are there. It should work.
Great thanks!
I have a command returning a promise:
and a function in an angular controller:
I would expect that when my onSuccess function is called, the response parameter would be the unwrapped promise result from the command. However, when I inspect the response parameter it appears to be a command object of some sort. It has the following structure:
Is this intentional? Why doesn't it just return the result to the onSuccess function?
Thanks