anycable / anycable-rails

AnyCable for Ruby on Rails applications
https://anycable.io
MIT License
495 stars 35 forks source link

[DRAFT] Whispering backport for Action Cable #201

Closed lHydra closed 7 hours ago

lHydra commented 3 months ago

What is the purpose of this pull request?

Add whispering backport for Action Cable

Is there anything you'd like reviewers to focus on?

@palkan Hi! Could you please take a look at the MR? Did I understand the essence of the issue correctly?

That is, we want to have the following code in our Rails application:

import consumer from "channels/consumer"

consumer.subscriptions.create("ChatChannel", {
  whisper(payload) {
    this.perform("whisper", payload);
  }
})

Which will trigger the execution of the predefined #whisper method from the channel?

Checklist

Closes https://github.com/anycable/anycable-rails/issues/198

palkan commented 2 months ago

Thanks for the PR! (And sorry for later response).

predefined #whisper method from the channel?

Now, we use as custom command for whispering (so, the final JSON would be {"command":"whisper", "identifier": "...","data": <payload>}). It would be hard to achieve this functionality with @rails/actioncable; supporting AnyCable JS would be enough. Here is how channel.whisper(...) is implemented there:

Thus, we don't need a Channel #whisper method, all can be done within the Subscriptions class.

palkan commented 7 hours ago

Thanks!

I've updated and merged it into #205