cklmercer/vue-events

Event Extensions

Closed this issue · 3 comments

Thanks for vue-events, this plugin reminds me of a possible way to implement the suggestion/request in the following issue: vuejs/vue-rx#5

It would be awesome to attach robust support for RxJS observables directly into the Vue event system, any feedback on the best way to do that is most appreciated.

NOTE: There is the vue-rx plugin, but it seems to curtail the full usage of RxJS in Vue by it's overly simple way of just auto subscribing to any observable it discovers.

I'm not very familiar with RxJS, but after a little research it's definitely got my attention. Let me dig a bit deeper and hopefully I can provide you with some insight.

If, in the mean time, you can provide me with additional details, as to what specifically you would like to do on the Vue side of things, I would be happy to try and help.

I'm closing this issue, as it's not an actual issue with the plugin, but I will continue to follow this thread.

Sounds good, it would be a matter of integrating the RxJS fromEvent operator, which is here: http://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#static-method-fromEvent

This would create an observable that captures events on a specified DOM node. Then there should be two ways to subscribe (observe) the captured event stream:

  1. In a function within the Vue component whose template makes the stream request.
  2. In a module outside the Vue component for more elaborate stream handling.

In the first use case the stream can be processed and provide data directly to the data-object. In the second case the stream is passed out of the Vue component to a target module for stream graphs that involve multiple connected observables and observers. Then at different observer junctions the data produced by such an elaborate graph can be proxied back to one or more Vue component data-objects.

I think this would make everyone happy and the solution robust. It would also be cool if the fromEvent capture function in Vue would have the same convention as Vue already uses. Maybe using @stream to distinguish it from @event.

So the essential signature could be:

@stream(dom-node, event-type, component-handler | module-handler)