Posted By

RichardCustance on 09/13/11


Tagged

javascript jquery widgets Rx reactive rxjs


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

spee66


jQuery UI Widget + RxJS Example (mouseover firehose)


 / Published in: jQuery
 

URL: http://www.sage.co.uk/devblog

  1. $.widget("example.firehose", {
  2. _create: function () {
  3. // Closure
  4. var self = this;
  5. var o = self.options;
  6. var el = self.element;
  7.  
  8. // Create a Reactive JavaScript (RxJS) observable, which creates a sequence of
  9. // mouse move events
  10. o.firehose = $(document).toObservable("mousemove").Select(function (eventData) {
  11. return eventData;
  12. });
  13.  
  14. // Subscribe the DOM element to which we are attached to the mousemove events
  15. o.firehose.Subscribe(function (eventData) {
  16. // Write the X and Y coordinates into the DOM element we have attached to
  17. $(el[0]).text(eventData.offsetX + "," + eventData.offsetY);
  18. });
  19. }
  20. });

Report this snippet  

You need to login to post a comment.