dotJEM / angular-routing

Enhanced state based routing for Angular applications!
https://dotjem.github.io/angular-routing/
MIT License
75 stars 9 forks source link

Allow transitions to wait for a promise. #81

Closed jeme closed 10 years ago

jeme commented 10 years ago

from #80.

Either allow for returning a promise in a transition handler, or a syntax like proposed in #80 where we call a method on $transition giving it a promise (or value which just resolves instantaneously)

This would be very much in line with the rest of the solution.

jeme commented 10 years ago

after some investigations, this requires another major refactoring of goto.

Thats not a bad thing as goto was intented to be further refactored, but it delays the implementation of this issue.

jeme commented 10 years ago

Pushing this to v0.7 as the re-factoring will change a great deal of things, which I won't guarantee to be fully backwards compatible with the 0.6.x path...

jeme commented 10 years ago

@groner FYI you are now able to return promises from transition handlers and the transition will either proceed when resolved or abort it the promise returned is rejected.

So your syntax would not be:

if (formIsDirty) {
  $transition.suspendUntil($modal(...));
}

but rather

if (formIsDirty) {
  return $modal(...);  //Assuming that modal will result in a promise.
}
groner commented 10 years ago

@jeme Pretty cool. I look forward to trying it!