vue-pusher

1.1.0 • Public • Published

Vue Pusher

A pusher plugin for vue.js

Usage

Install the plugin like any other plugin. :)

var Vue = require('vue');
 
Vue.use(require('vue-pusher'), {
    api_key: 'xxxxxx',
    options: {
        cluster: 'ap1',
        encrypted: true,
    }
});

Manually using the pusher instance.

Inside your components, you just need to access the $pusher object.

export default {
    ready () {
        var channel = this.$pusher.subscribe('dashboard');
 
        channel.bind('user.log', ({ log }) => {
            console.log(`User ${log.user.name} has ${log.action} at ${log.time}`);
        });
    }
}

Subscribing to a channel.

Subscribing to a channel providers a callback where you can bind events.

this.$pusher.subscribe('dashboard', channel => {
    channel.bind('user.log', ({ log }) => {
        console.log(`User ${log.user.name} has ${log.action} at ${log.time}`);
    });
});

Unsubscribing to a channel.

this.$pusher.unsubscribe('dashboard');

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.0
    1,992
    • latest

Version History

Package Sidebar

Install

npm i vue-pusher

Weekly Downloads

2,396

Version

1.1.0

License

MIT

Unpacked Size

3.07 kB

Total Files

4

Last publish

Collaborators

  • joshuacerbito
  • jaggy