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

vue-echo

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-echo

Vue integration for the Laravel Echo library.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3K
increased by54.31%
Maintainers
1
Weekly downloads
 
Created
Source

vue-echo

Vue integration for the Laravel Echo library.

Install

npm install vue-echo --save

Usage

Initialise

First you'll need to register the plugin and optionally initialise the Echo instance.

import VueEcho from 'vue-echo';
  
Vue.use(VueEcho, {
    broadcaster: 'pusher',
    key: 'PUSHER KEY',
});

/**
 * Alternatively you can pass an echo instance:
 * ********************************************
 * import Echo from 'laravel-echo';
 * 
 * let EchoInstance = new Echo({
 *     broadcaster: 'pusher',  
 *     key: 'PUSHER KEY',
 * });
 * Vue.use(VueEcho, EchoInstance);
 */

Using Echo

Once vue-echo is registered, every vue instance is able to to subscribe to channels and listen to events through the this.$echo property on the connection you specified earlier.

Subscribe your Vue instance to a single channel

You can subscribe a vue instance to a single standard channel if needed and define your events.

var vm = new Vue({
    channel: 'blog'
    echo: {
      'BlogPostCreated': payload => {
        console.log('blog post created', payload);
      },
      'BlogPostDeleted': payload => {
        console.log('blog post deleted', payload);
      }
    }
  })
Subscribing to channels

Laravel echo allows you to subscribe to; normal, private and presence channels.

In the example above we subscribed to a standard channel.

Private channel

If you would like to subscribe to private channel instead, prefix your channel name with private:

var vm = new Vue({
    channel: 'private:team.1'
    echo: {
      'BlogPostCreated': payload => {
        console.log('blog post created', payload);
      },
      'BlogPostDeleted': payload => {
        console.log('blog post deleted', payload);
      }
    }
  })
Presence channel

If you would like to subscribe to presence channel instead, prefix your channel name with presence:

var vm = new Vue({
    channel: 'presence:team.1.chat'
    echo: {
      'NewMessage': payload => {
        console.log('bNew message from team', payload);
      }
    }
  })

Keywords

FAQs

Package last updated on 30 Oct 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