1

I wan't to get text change events from input but limit them to 3 per second.

Rx support my wish? how can I achieve this ability?

Chen Kinnrot
  • 20,609
  • 17
  • 79
  • 141

1 Answers1

0

Assuming you already have the Observeable, insert a call to throttle(333) before you consume should do the trick. (333= miliseconds which is 1000/3 which gives you 3 chars per second).

a very simple sample:

 $(document).ready(function () {
   var mainCanvas = $("#TextBox1");
   var observable = Rx.Observable.FromHtmlEvent(mainCanvas.context, "keypress");

   var throttle = observable.throttle(333);

   throttle.subscribe(function (next) {
         $('div#test').append(String.fromCharCode( next.charCode)); 
        }
   );
 });
rene
  • 41,474
  • 78
  • 114
  • 152