1

私のアプリケーションでは、Rails 5を使用して、ローダーシステムを持っていて、ajaxSendajaxCompleteを捕まえて、cssでローダーをアニメーション化しました。ActionCableウェブソケットでjsローダーを処理するには?

$(document).bind('ajaxSend',() => { 
    ... 
}) 

$(document).bind('ajaxComplete',() => { 
    ... 
}) 

私の質問は簡単ですが、ウェブソケットで同じことをする方法は? :)

答えて

0
function connectToYourChannel() { 
    // start your animation here 
    subscription = App.cable.subscriptions.create("YourChannel") { 
     connected: function() { 
      // this code will execute when you successfully subscribe 
      // to your channel; 
      // end your animation here 
     } 
    } 
} 

BTW:接続プロセスが非常に高速です。 99%のケースでローディングメッセージは必要ありません。

関連する問題