[DRAFT] Whispering backport for Action Cable
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
- [ ] I've added tests for this change
- [ ] I've added a Changelog entry
- [ ] I've updated documentation
Closes https://github.com/anycable/anycable-rails/issues/198
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:
- https://github.com/anycable/anycable-client/blob/eb0d8bb26dd04982f605429523236692bc33663f/packages/core/channel/index.js#L129
- https://github.com/anycable/anycable-client/blob/eb0d8bb26dd04982f605429523236692bc33663f/packages/core/action_cable/index.js#L130
Thus, we don't need a Channel #whisper method, all can be done within the Subscriptions class.
Thanks!
I've updated and merged it into #205