views:

37

answers:

1

I'm trying to understand Reactive JS. In JQuery I can trigger custom events as

$(document).bind('eventbus', function(e, d) { console.log(d);});
$(document).trigger('eventbus', 'test');

and pass around data (i.e. 'test'). It's not clear how to do this in RxJS. I could try to convert the jquery events as

var observable = $(document).ToObservable('eventbus');

but observable returns the event object but not my data object. How do I trigger custom events with data using RxJS? Do I always need to piggyback on some other event type? My goal is to create a simple eventbus using RxJS.

A: 

you should use Rx.Observable.FromJQueryEvent to get an observable from a jQuery object, instead of the plain .ToObservable.

This link will help you: jQuery + RxJS

Eduardo