如何使用ActionCable websockets处理js加载器
How to handle js loader with ActionCable websockets?
所以在我使用Rails 5的应用程序中,我有一个加载器系统,它捕获ajaxSend
和ajaxComplete
来动画css中的加载器。
$(document).bind('ajaxSend', () => {
...
})
$(document).bind('ajaxComplete', () => {
...
})
我的问题很简单,如何用websockets做同样的事情?:)
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%的情况下,你不需要加载消息
相关文章:
- 当脚本由system.js加载时,如何要求('electron')
- 使用JS加载HTML元素
- Mailchimp内联表单验证不适用于JS加载的HTML
- 使用Microsoft Office.js加载项进行自动身份验证
- PHP 图表 js 加载 mysql 和接口
- 节点JS加载JS&ejb文件中的css文件
- 使用springy.js加载多个图形时闪烁画布
- 何时需要JS加载所有模块
- Backbone Js加载部件中的应用程序
- 击倒没有定义?确实需要js加载任何内容
- 使用三个js加载三维模型示例
- Knockout.JS加载顺序问题
- jquery选项卡和js加载内容
- Features.js-加载静态内容
- MongoDB脚本和CSV文件:我可以使用require.js加载jquery.CSV吗
- Ember.js加载模板上的Per-Model Promise状态
- 延迟js加载的最佳方式
- 使用D3.js加载用于可视化的本地数据
- 用angular.js加载更多分页|按钮dos'不要藏起来
- 如何使用队列.js和 D3.js 加载多个文件