laravel-echo

  • Version 1.17.1
  • Published
  • 222 kB
  • No dependencies
  • MIT license

Install

npm i laravel-echo
yarn add laravel-echo
pnpm add laravel-echo

Overview

Laravel Echo library for beautiful Pusher and Socket.IO integration

Index

Classes

class Channel

abstract class Channel {}
  • This class represents a basic channel.

property options

options: any;
  • The Echo options.

method error

abstract error: (callback: Function) => this;
  • Register a callback to be called anytime an error occurs.

method listen

abstract listen: (event: string, callback: Function) => this;
  • Listen for an event on the channel instance.

method listenForWhisper

listenForWhisper: (event: string, callback: Function) => this;
  • Listen for a whisper event on the channel instance.

method notification

notification: (callback: Function) => this;
  • Listen for an event on the channel instance.

method stopListening

abstract stopListening: (event: string, callback?: Function) => this;
  • Stop listening to an event on the channel instance.

method stopListeningForWhisper

stopListeningForWhisper: (event: string, callback?: Function) => this;
  • Stop listening for a whisper event on the channel instance.

method subscribed

abstract subscribed: (callback: Function) => this;
  • Register a callback to be called anytime a subscription succeeds.

class Connector

abstract class Connector<
TPublic extends Channel,
TPrivate extends Channel,
TPresence extends PresenceChannel
> {}

    constructor

    constructor(options: any);
    • Create a new class instance.

    property options

    options: any;
    • Connector options.

    method channel

    abstract channel: (channel: string) => TPublic;
    • Get a channel instance by name.

    method connect

    abstract connect: () => void;
    • Create a fresh connection.

    method csrfToken

    protected csrfToken: () => null | string;
    • Extract the CSRF token from the page.

    method disconnect

    abstract disconnect: () => void;
    • Disconnect from the Echo server.

    method leave

    abstract leave: (channel: string) => void;
    • Leave the given channel, as well as its private and presence variants.

    method leaveChannel

    abstract leaveChannel: (channel: string) => void;
    • Leave the given channel.

    method presenceChannel

    abstract presenceChannel: (channel: string) => TPresence;
    • Get a presence channel instance by name.

    method privateChannel

    abstract privateChannel: (channel: string) => TPrivate;
    • Get a private channel instance by name.

    method setOptions

    protected setOptions: (options: any) => any;
    • Merge the custom options with the defaults.

    method socketId

    abstract socketId: () => string;
    • Get the socket_id of the connection.

    class Echo

    class Echo<T extends keyof Broadcaster> {}
    • This class is the primary API for interacting with broadcasting.

    constructor

    constructor(options: EchoOptions<T>);
    • Create a new class instance.

    property connector

    connector: any;
    • The broadcasting connector.

    property options

    options: EchoOptions<T>;
    • The Echo options.

    method channel

    channel: (channel: string) => Broadcaster[T]['public'];
    • Get a channel instance by name.

    method connect

    connect: () => void;
    • Create a new connection.

    method disconnect

    disconnect: () => void;
    • Disconnect from the Echo server.

    method encryptedPrivate

    encryptedPrivate: (channel: string) => Broadcaster[T]['encrypted'];
    • Get a private encrypted channel instance by name.

    method join

    join: (channel: string) => Broadcaster[T]['presence'];
    • Get a presence channel instance by name.

    method leave

    leave: (channel: string) => void;
    • Leave the given channel, as well as its private and presence variants.

    method leaveAllChannels

    leaveAllChannels: () => void;
    • Leave all channels.

    method leaveChannel

    leaveChannel: (channel: string) => void;
    • Leave the given channel.

    method listen

    listen: (
    channel: string,
    event: string,
    callback: Function
    ) => Broadcaster[T]['public'];
    • Listen for an event on a channel instance.

    method private

    private: (channel: string) => Broadcaster[T]['private'];
    • Get a private channel instance by name.

    method registerAxiosRequestInterceptor

    registerAxiosRequestInterceptor: () => void;
    • Register an Axios HTTP interceptor to add the X-Socket-ID header.

    method registerInterceptors

    registerInterceptors: () => void;
    • Register 3rd party request interceptiors. These are used to automatically send a connections socket id to a Laravel app with a X-Socket-Id header.

    method registerjQueryAjaxSetup

    registerjQueryAjaxSetup: () => void;
    • Register jQuery AjaxPrefilter to add the X-Socket-ID header.

    method registerTurboRequestInterceptor

    registerTurboRequestInterceptor: () => void;
    • Register the Turbo Request interceptor to add the X-Socket-ID header.

    method registerVueRequestInterceptor

    registerVueRequestInterceptor: () => void;
    • Register a Vue HTTP interceptor to add the X-Socket-ID header.

    method socketId

    socketId: () => string;
    • Get the Socket ID for the connection.

    class EventFormatter

    class EventFormatter {}
    • Event name formatter

    constructor

    constructor(namespace: string | boolean);
    • Create a new class instance.

    method format

    format: (event: string) => string;
    • Format the given event name.

    method setNamespace

    setNamespace: (value: string | boolean) => void;
    • Set the event namespace.

    Interfaces

    interface PresenceChannel

    interface PresenceChannel extends Channel {}
    • This interface represents a presence channel.

    method here

    here: (callback: Function) => this;
    • Register a callback to be called anytime the member list changes.

    method joining

    joining: (callback: Function) => this;
    • Listen for someone joining the channel.

    method leaving

    leaving: (callback: Function) => this;
    • Listen for someone leaving the channel.

    method whisper

    whisper: (eventName: string, data: any) => this;
    • Send a whisper event to other clients in the channel.

    Package Files (5)

    Dependencies (0)

    No dependencies.

    Dev Dependencies (20)

    Peer Dependencies (0)

    No peer dependencies.

    Badge

    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/laravel-echo.

    • Markdown
      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/laravel-echo)
    • HTML
      <a href="https://www.jsdocs.io/package/laravel-echo"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>