admin管理员组文章数量:1123692
Currently trying to implement a website with Ruby as my backend and React as my frontend. Checked that my frontend is already subscribed to the correct channel. When a new Model (TourGuidePackage) is created, it is able to invoke the after_commit method: broadcast_update.
To simulate the potential changes to Package Details like the name, i entered into a separate Ruby Console. Running
request = TourGuidePackage.last
request.name = "Changed Name"
request.save
The Rails logger in my broadcast_update runs normally but the ActionCable is not invoked. What is the potential issue?
def broadcast_update
Rails.logger.info "Broadcast update ID: ${self.id}"
payload = {id: self.id, message: "successfully updated"}
ActionCable.server.broadcast(packageChannel, payload)
I tried to check if there is a potential disconnect in the user during the wait time but can confirm that the user was on. Also checked that broadcast_update is working for creation.
A weird thing i noticed is that when i did
ActionCable.server.broadcast(packageChannel, {id: 1, message: "successfully updated"})
on my Ruby Rails, it results in a nil and i cannot view the message on my frontend
I'm expecting to see the broadcasted message on the frontend but the message is not getting through. I'm hoping to stick to using ActionCable to achieve the communication between the frontend and backend
For context, i tried after_save and after_commit.
Appreciate any feedbacks for improvement
本文标签: reactjsFacing some issues with ActionCableStack Overflow
版权声明:本文标题:reactjs - Facing some issues with ActionCable - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736582573a1944966.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论