Hi

First of all, thanks for your code example. I was running into the problem 
of watchers being fired over and over on an app Im developing, and your 
ordered initialization code helped a lot.

Sorry for what is probably a newbie question, but I am looking at the 
broadcastAppInitialized function, specifically using $browswer.defer for 
setting initialized=true and broadcasting final initialization. For one, I 
cant seem to find the documentation for $browser anywhere, and I even see a 
post that suggests it might be deprecated (see 
https://github.com/angular/angular.js/issues/532). Is there some hidden 
documentation somewhere?

Also, I tried changing the function to:

 var broadcastAppInitialized = function(){
           initialized = true;
           $rootScope.$broadcast( APPLICATION_INITIALIZED );
 }

(This makes unit testing a little easier as I dont have to mock 
$browser.defer to set initialized=true)

I can see no difference in how the code behaves using this simpler method. 
Can I ask, what problem were you trying to solve by wrapping this in the 
$browser.defer?

Thanks 

Doug

On Monday, October 28, 2013 6:55:44 AM UTC-4, Tobias Gesellchen wrote:
>
> Hi group,
>
> as already asked or suggested in several posts, you sometimes need to wait 
> for http backend calls to finish before your AngularJS app is regarded as 
> being initialized and usable.
>
> We also stumbled over the problem of $watch triggers or $on events being 
> fired too early (before the http requests had been finished loading data) 
> in the application lifecycle, so we have built a dedicated "initialization 
> service" which enables us to configure the loading order of services and 
> helps us configuring our controllers and $scopes to be initialized 
> correctly.
>
> You can find a more thorough description at our 
> blog<http://blog-it.hypoport.de/2013/10/28/angularjs-ordered-init-async-promise/>an
>  a working demo at 
> jsfiddle <http://jsfiddle.net/gesellix/xxKjw/>.
>
> We would like to get some feedback on our implementation. Please have a 
> look at our code and provide some feedback in this group. Questions are 
> welcome as well!
>
> Thanks!
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to