Last Updated: October 17, 2017
·
822
· ydeshayes

Asynchronous on-change function execution with AngularJS

On-change event is awesome, but when you have a huge things to do when this event happend (for example when the user write something in an input) the GUI will freeze like hell !

I write a directive to do that work asynchronously :

https://github.com/institut-de-genomique/Ultimate-DataTable/blob/master/src/directives/udt-change.js

I use $interval angularjs function (setInterval with an $apply at the end) to control a tick. On every tick I check if I have to run the function.

To run the function on the right context I use a watcher that I disable right after his execution.

The goal I try to achieve is to use promise so that the function don't run concurently, but for now this solution work fine.

Have a fresh tip? Share with Coderwall community!

Post
Post a tip