[AngularJS] Re: event after angular has done its work and is idle (after digest loop)

2014-02-12 Thread Sander Elias


Oh, I forgot,

You can use my sample to fire an event too. just put it in the signal 
function.
the scope you are watching is reachable there with rs
so rs.$broadcast('DigestIdle') will do what you want.

Regards
Sander

-- 
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 angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.


[AngularJS] Re: event after angular has done its work and is idle (after digest loop)

2014-02-12 Thread Sander Elias
Hi Martin,

Well, I have very mixed feelings about this. There are a few rare use-cases 
where it's a bit of a miss. Like your own one. However, If this gets into 
Angular itself, it will be used for all kind of things where it really 
wouldn't be suited. And all the edge-cases that evolve from that needs to 
be supported. 
To be short, No I don't think it is a good idea.

Regards
Sander
 

-- 
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 angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.


[AngularJS] Re: event after angular has done its work and is idle (after digest loop)

2014-02-12 Thread Martin Kuhn
Sander, thank you very much, looks good...

BTW, wouldn't it be useful when angular provides an event when digests 
finished?

Regards
Martin

Am Mittwoch, 12. Februar 2014 12:13:16 UTC+1 schrieb Sander Elias:
>
> Hi Martin,
>
> I took an existing plunk where I posted this.  However, once in a while 
> one needs to hit the save button ;)
> It should work now.
>
> Regards
> Sander
>
>

-- 
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 angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.


[AngularJS] Re: event after angular has done its work and is idle (after digest loop)

2014-02-12 Thread Sander Elias
Hi Martin,

I took an existing plunk where I posted this.  However, once in a while one 
needs to hit the save button ;)
It should work now.

Regards
Sander

-- 
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 angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.


[AngularJS] Re: event after angular has done its work and is idle (after digest loop)

2014-02-12 Thread Martin Kuhn

Hi Sander,

thank you for your effort!

but it seems that the plunker is not correct...

Regards,
Martin

Am Mittwoch, 12. Februar 2014 10:23:27 UTC+1 schrieb Sander Elias:
>
> you can see it in action in this plunker: 
> http://plnkr.co/edit/Sud2Y0VFy3SH3QtZojg7?p=preview
>
>
>

-- 
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 angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.


[AngularJS] Re: event after angular has done its work and is idle (after digest loop)

2014-02-12 Thread Sander Elias


Hi Martin,

Ah, well, that’s indeed a good reason to want this. I don’t have a 
waterproof solution for this, but the wrote the following for you. It will 
trigger when no digest has occurred for 500ms


app.run(['seDigestwatcher', '$rootScope', function (seDigestwatcher, rS) {
   // Set up the digestwatcher in the run, so it's available during 
   // the whole lifetime of the app.
   seDigestwatcher.setScope(rS); //Make it watch the rootscope.
   seDigestwatcher.registerDigests(); //start watching.
}]);

app.factory('seDigestwatcher', [
   function() {
  var timeOutId,
 rs = null;
 me = this,
 digestCounter = 0;
 unWatch = null;
  this.registerDigests = function() {
 console.log('start watching');
 unWatch = rs.$watch(function() {
digestCounter += 1;
me.cancel(); //cancel pening timeout
// set up a timeout to signal after no new digest
// is starterd within 500Ms. If you have really
// long running functions, or ajax stuff
// you might need to set a bigger timeout
timeOutId = setTimeout(me.signal,500) ;
 });
  };
  this.deRegisterDigests= function () {
 if (unWatch) {
me.cancel();
unWatch();
 }
  };

  this.cancel = function () {
 if (timeOutId) {
clearTimeout(timeOutId);
timeOutId = null;
 }
  };

  this.setScope = function (scope) {
 rs=scope;
  };

  this.signal = function () {
 me.cancel();
 console.log(digestCounter);
  };

  return { 
 registerDigests: me.registerDigests,
 deRegisterDigests: me.deRegisterDigests,
 setScope : me.setScope
  };
   }
]);

you can see it in action in this plunker: 
http://plnkr.co/edit/Sud2Y0VFy3SH3QtZojg7?p=preview
Just adapt the signal function to what you need it to do.

Regards
Sander

-- 
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 angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.


[AngularJS] Re: event after angular has done its work and is idle (after digest loop)

2014-02-11 Thread Martin Kuhn
Hi Sander,

I would need it for testing with Selenium / cucumber in a Java environment. 
Currrently we wait a certain amount oft time...

Regards,
Martin

-- 
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 angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.


[AngularJS] Re: event after angular has done its work and is idle (after digest loop)

2014-02-11 Thread Sander Elias
Hi Martin,

What is it you are trying to accomplish? What is your use-case for this. 

Regards
Sander

-- 
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 angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.