Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-rx

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-rx

RxJS bindings for Vue

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7K
increased by5.38%
Maintainers
1
Weekly downloads
 
Created
Source

vue-rx

Simple RxJS binding for Vue.js.

Installation

  • With global scripts: just make sure to include vue-rx.js after Vue.js and RxJS. It will be installed automatically.

  • With NPM:

    var Vue = require('vue')
    var Rx = require('rx')
    var VueRx = require('vue-rx')
    
    // tada!
    Vue.use(VueRx, Rx)
    
    // The second argument is optional if you are not using RxJS but other generic observable implementations:
    Vue.use(VueRx)
    

Usage

With NPM:

var Vue = require('vue')
var Rx = require('rx')
var VueRx = require('vue-rx')

// tada!
Vue.use(VueRx, Rx)

// provide Rx observables with the `subscriptions` option
new Vue({
  el: '#app',
  subscriptions: {
    msg: messageObservable
  }
})
<!-- bind to it normally in templates -->
<div>{{ msg }}</div>

The subscriptions options can also take a function so that you can return unique observables for each component instance:

Vue.component('foo', {
  subscriptions: function () {
    return {
      msg: Rx.Observable.create(...)
    }
  }
})

Using with Alternative Observable Implementations

You can use this plugin with other observable implementations, as long as it implements the .subscribe and .dispose / .unsubscribe interface. For example, you can use it with most.js or Falcor streams.

$watchAsObservable

This feature requires using RxJS.

This is a prototype method added to instances. You can use it to create an observable from a value watcher:

created:function () {
  this.$watchAsObservable('a')
    .subscribe(function (val) {
      console.log('stream value', val)
    },function (err) {
      console.error(err)
    },function () {
      console.log('complete')
    })
}

Example

See /example for a simple example.

License

MIT

Keywords

FAQs

Package last updated on 05 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc