Skip to content

Commit

Permalink
Code split Echo and Pusher
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Mar 2, 2025
1 parent c280caa commit 19350ce
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions resources/js/components/Echo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import LaravelEcho from 'laravel-echo';
import Pusher from 'pusher-js';
window.Pusher = Pusher;

class Echo {
constructor() {
this.configCallbacks = [];
Expand All @@ -16,7 +12,14 @@ class Echo {
this.bootedCallbacks.push(callback);
}

start() {
async start() {
const [{ default: LaravelEcho }, { default: Pusher }] = await Promise.all([
import('laravel-echo'),
import('pusher-js'),
]);

window.Pusher = Pusher;

let config = {
...Statamic.$config.get('broadcasting.options'),
csrfToken: Statamic.$config.get('csrfToken'),
Expand Down

0 comments on commit 19350ce

Please sign in to comment.