Not receiving data!
dcalixto opened this issue · 13 comments
Hello! @kesha-antonov thank you for the package, but is not receiving or something that i did wrong?
here is the configuration:
createSocket() {
let actionCable = ActionCable.createConsumer("ws://localhost:3000/cable");
this.chats = actionCable.subscriptions.create(
{
channel: "NotificationChannel"
},
{
connected: () => {},
received: data => {
this.fetchNewNotification();
}
}
);
}
Hey @dcalixto
Can you post please app/channels/notifications_channel.rb
?
Sure @kesha-antonov !
class NotificationChannel < ApplicationCable::Channel
def subscribed
stream_from "notification_channel"
end
def unsubscribed
# Any cleanup needed when channel is unsubscribed
end
end
Try this
createSocket() {
const actionCable = ActionCable.createConsumer("ws://localhost:3000/cable");
const cable = new Cable({})
const channel = cable.setChannel(
`notification_channel`
actionCable.subscriptions.create({
channel: 'NotificationChannel'
})
)
channel
.on( 'connected', () => { console.log('connected') } )
.on( 'received', data => {
console.log('received', data)
this.fetchNewNotification()
} )
)
}
@kesha-antonov sorry, but still not fetching or receiving data!
Even in the logs shows nothing!
@kesha-antonov is anything that i can help or try?
Try
ActionCable.startDebugging()
to see the logs
And any output in rails server console?
@kesha-antonov just this!
@kesha-antonov just this!
Seems like all is ok - ws connected
.on( 'connected', () => { console.log('connected') } )
should work
I can create example example with rails app and double check that everything is fine but only on weekend
@kesha-antonov , great! :)
hey @kesha-antonov , my fault sorry for the delay! is working. i just forget to add the data.notifications on set state of this.fetchNewNotification() function!
thank you very much for your support and for the package :)
how to use this in a functional component