@@ -15,29 +15,40 @@ var vueEcho = (function (exports, LaravelEcho) {
1515    return  channels [ target ] ; 
1616  } 
1717
18+   const  hooks  =  [ ] ; 
19+   function  addHookFunction ( func )  { 
20+     hooks . push ( func ) ; 
21+   } 
22+   function  onChange ( ...params )  { 
23+     hooks . forEach ( func  =>  func ( ...params ) ) ; 
24+   } 
1825  function  join ( channelName ,  options )  { 
1926    const  { 
2027      isPrivate
2128    }  =  options ; 
2229    console . debug ( '[Echo] joinChannel -' ,  isPrivate  ? 'private-'  +  channelName  : channelName ) ; 
2330    isPrivate  ? this . private ( channelName )  : this . channel ( channelName ) ; 
31+     onChange ( ) ; 
2432  } 
2533  function  leave ( channelName )  { 
2634    const  targetChannel  =  getChannel ( this . connector . channels ,  channelName ) ; 
2735    console . debug ( '[Echo] leaveChannel -' ,  targetChannel . name ) ; 
2836    this . leave ( channelName ) ; 
37+     onChange ( ) ; 
2938  } 
3039  function  subscribe ( channelName ,  eventName ,  callback )  { 
3140    const  targetChannel  =  getChannel ( this . connector . channels ,  channelName ) ; 
3241    targetChannel . listen ( eventName ,  res  =>  { 
3342      if  ( callback )  callback ( res ) ; 
3443    } ) ; 
3544    console . debug ( '[Echo] subscribeEvent -' ,  targetChannel . name ,  eventName ) ; 
45+     onChange ( ) ; 
3646  } 
3747  function  unsubscribe ( channelName ,  eventName )  { 
3848    const  targetChannel  =  getChannel ( this . connector . channels ,  channelName ) ; 
3949    targetChannel . stopListening ( eventName ) ; 
4050    console . debug ( '[Echo] unsubscribeEvent -' ,  targetChannel . name ,  eventName ) ; 
51+     onChange ( ) ; 
4152  } 
4253  function  getChannels ( )  { 
4354    return  this . connector . channels ; 
@@ -79,6 +90,7 @@ var vueEcho = (function (exports, LaravelEcho) {
7990      Vue . prototype . $echo  =  exports . Echo  =  {  ...laravelEcho 
8091      } ; 
8192      Object . setPrototypeOf ( exports . Echo ,  { 
93+         onChange : addHookFunction , 
8294        join : join . bind ( laravelEcho ) , 
8395        leave : leave . bind ( laravelEcho ) , 
8496        subscribe : subscribe . bind ( laravelEcho ) , 
0 commit comments