-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Support asynchronous module.run() #4003
Comments
This is not so easy but should be looked into. |
The way Jasmine does this is by setting a flag, that will let the function run and wait for the callback until the flag is set to Basically something like this: var flag = false;
$http(...).success(flag = true);
$timeout(function () {
flag = true;
// Or add some error handling stuff here
}, 5000);
while (!flag) {}; It's not pretty, but should do the job. The code above isn't tested, so you may need to modify it a bit. It's getting late here. Hopefully something to get you by until something a bit prettier comes along. |
+1 |
On a second though, this does lead to the inability to draw fancy loading screen using angular directives... |
+1 |
Doesn't |
This is more for async module init support. With that said, I no longer need this in my current projects. |
@shahata |
+1 check if the run function returns a promise, then only procceed when it's resolved. since |
+1 |
+1 embarrassing that this got ignored |
any idea when this is going to land? so frustrating to have to move initialization stuff to resolve in the router, mainly because sometimes the initialization code is url agnostic (aka, must be initialized for any type of URL that the user arrives at your SPA) |
i don't think angular will be receiving any enhancements henceforth. they're all being added to angular 2.0 |
how long the half-assed it's embarrassing |
+1 |
@btford is looking at how the use cases around this could be supported via the new router rather than inside run blocks. |
+1 |
3 similar comments
+1 |
+1 |
+1 |
The main problem we have is the |
@lgalfaso - perhaps you could look into this a bit more as part of your |
I know it's just a workaround, but I've normally solved the issue of having some async bootstrapping logic by using angular ui router and having a root abstract state in combination with resolve. The root abstract state has to be always resolved first, so it's a good place to load settings, display loading animations, etc. |
+1 |
It's been two years since issue was opened and there is still no good solution |
@vladmiller There are solutions but perhaps you do not feel that they are good:
Putting non-trivial application work inside |
@petebacondarwin I would disagree with you; everyone expect angluar to be simple and intuitive, instead you have to either implement your own async bootstrap module or bootstrap module in different place. In my opinion this makes angular more complex. Can you also explain what do you mean when saying that async code in Apologies for my previous rude comment. |
@petebacondarwin I fail to see how it makes it difficult to test. if you place the initialization code in a service, you can just watch/mock/compare the results you'll be expecting from the http backend mock, regardless if it's being executed inside a |
How it's going? |
Another approach: http://plnkr.co/edit/8XGSNOzzRGvgNSSnXx3M?p=preview |
@petebacondarwin solution worked for me |
Since there are workarounds and supporting async run blocks would add complexity to the bootstrap I don't think we will be implementing this feature. |
+1 for this feature |
+1 |
1 similar comment
+1 |
@petebacondarwin solution works good. |
+1. :( |
+1 |
3 similar comments
+1 |
+1 |
+1 |
We are not going to do this. |
+100, all the work arounds are terrible. |
@Eduardo-Julio - we are not going to implement this feature as it would make the bootstrap of AngularJS applications much more complex. Adding further |
We want to issue a few $http calls in the module run block, ideally, the run should finish only after the $http and processing finishes before the dom compiling happens.
The text was updated successfully, but these errors were encountered: