actioncable-vue icon indicating copy to clipboard operation
actioncable-vue copied to clipboard

Connect action cable manually

Open pribadi1st opened this issue 2 years ago • 0 comments

Hi, i am new to actioncable, so i want to connect to rails server using actioncable-vue but not instantly, so user has to open 1 specific page to initiate the connection

i am trying follow the documentation which is methods() { connectServer() { // You can optionally pass in a connection URL string // You can optionally pass in a function that returns a connection URL // You can choose not to pass in anything and it'll reconnect with the connection URL provided during setup. const url = useRuntimeConfig().public.VITE_APP_SOCKET_URL const token = useCookie('bearerToken').value this.$cable.connection.connect( ws://localhost:3000/v1/cable?token=${token}, ); console.log("this hitter",${url}/?token=${token}) } } mounted() { this.connectServer() }

Expected behaviour it should connect after the page mounted

Additional context i tried to add 1 simple button to trigger the connection, function is working, do you know why my connection isnt initiated at the beginning ?

pribadi1st avatar Sep 13 '22 15:09 pribadi1st