> For the complete documentation index, see [llms.txt](https://kelby.gitbook.io/rails-beginner-s-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kelby.gitbook.io/rails-beginner-s-guide/action_cable/action_cable_coffee/subscriptions_and_subscription.md).

# Subscription

传递消息，以及真正干活的好手。

**传递消息到 Channel#action**

常用的：

```ruby
# 封装下面的 send
perform
```

其它：

```ruby
# 实质是 consumer.send -> connection.send
send
```

```
unsubscribe
```

创建 subscription 需要 channel.

常用方法 `perform` 可以在 Coffee 里调用 Channel 里的 action.

```
Subscription#perform -> Subscription#send -> Consumer#send -> Connection#send -> WebSocket#send
```

**回调响应，及真正干活**

我们可以(和普通 JS 一样)在它的基础上自定义方法，进行调用。
