@rails/actioncable 6.1.4 → 7.0.0-rc2
Sign up to get free protection for your applications and to get access to all the features.
- package/app/assets/javascripts/action_cable.js +229 -256
- package/app/assets/javascripts/actioncable.esm.js +491 -0
- package/app/assets/javascripts/actioncable.js +489 -0
- package/package.json +7 -10
- package/src/connection.js +1 -0
- package/src/connection_monitor.js +14 -15
- package/src/index.js +2 -0
- package/src/index_with_name_deprecation.js +2 -0
- package/src/subscription_guarantor.js +50 -0
- package/src/subscriptions.js +18 -2
- package/CHANGELOG.md +0 -77
package/src/subscriptions.js
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
import Subscription from "./subscription"
|
2
|
+
import SubscriptionGuarantor from "./subscription_guarantor"
|
3
|
+
import logger from "./logger"
|
2
4
|
|
3
5
|
// Collection class for creating (and internally managing) channel subscriptions.
|
4
6
|
// The only method intended to be triggered by the user is ActionCable.Subscriptions#create,
|
@@ -13,6 +15,7 @@ import Subscription from "./subscription"
|
|
13
15
|
export default class Subscriptions {
|
14
16
|
constructor(consumer) {
|
15
17
|
this.consumer = consumer
|
18
|
+
this.guarantor = new SubscriptionGuarantor(this)
|
16
19
|
this.subscriptions = []
|
17
20
|
}
|
18
21
|
|
@@ -29,7 +32,7 @@ export default class Subscriptions {
|
|
29
32
|
this.subscriptions.push(subscription)
|
30
33
|
this.consumer.ensureActiveConnection()
|
31
34
|
this.notify(subscription, "initialized")
|
32
|
-
this.
|
35
|
+
this.subscribe(subscription)
|
33
36
|
return subscription
|
34
37
|
}
|
35
38
|
|
@@ -50,6 +53,7 @@ export default class Subscriptions {
|
|
50
53
|
}
|
51
54
|
|
52
55
|
forget(subscription) {
|
56
|
+
this.guarantor.forget(subscription)
|
53
57
|
this.subscriptions = (this.subscriptions.filter((s) => s !== subscription))
|
54
58
|
return subscription
|
55
59
|
}
|
@@ -60,7 +64,7 @@ export default class Subscriptions {
|
|
60
64
|
|
61
65
|
reload() {
|
62
66
|
return this.subscriptions.map((subscription) =>
|
63
|
-
this.
|
67
|
+
this.subscribe(subscription))
|
64
68
|
}
|
65
69
|
|
66
70
|
notifyAll(callbackName, ...args) {
|
@@ -80,6 +84,18 @@ export default class Subscriptions {
|
|
80
84
|
(typeof subscription[callbackName] === "function" ? subscription[callbackName](...args) : undefined))
|
81
85
|
}
|
82
86
|
|
87
|
+
subscribe(subscription) {
|
88
|
+
if (this.sendCommand(subscription, "subscribe")) {
|
89
|
+
this.guarantor.guarantee(subscription)
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
confirmSubscription(identifier) {
|
94
|
+
logger.log(`Subscription confirmed ${identifier}`)
|
95
|
+
this.findAll(identifier).map((subscription) =>
|
96
|
+
this.guarantor.forget(subscription))
|
97
|
+
}
|
98
|
+
|
83
99
|
sendCommand(subscription, command) {
|
84
100
|
const {identifier} = subscription
|
85
101
|
return this.consumer.send({command, identifier})
|
package/CHANGELOG.md
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
## Rails 6.1.4 (June 24, 2021) ##
|
2
|
-
|
3
|
-
* Fix `ArgumentError` with ruby 3.0 on `RemoteConnection#disconnect`.
|
4
|
-
|
5
|
-
*Vladislav*
|
6
|
-
|
7
|
-
|
8
|
-
## Rails 6.1.3.2 (May 05, 2021) ##
|
9
|
-
|
10
|
-
* No changes.
|
11
|
-
|
12
|
-
|
13
|
-
## Rails 6.1.3.1 (March 26, 2021) ##
|
14
|
-
|
15
|
-
* No changes.
|
16
|
-
|
17
|
-
|
18
|
-
## Rails 6.1.3 (February 17, 2021) ##
|
19
|
-
|
20
|
-
* No changes.
|
21
|
-
|
22
|
-
|
23
|
-
## Rails 6.1.2.1 (February 10, 2021) ##
|
24
|
-
|
25
|
-
* No changes.
|
26
|
-
|
27
|
-
|
28
|
-
## Rails 6.1.2 (February 09, 2021) ##
|
29
|
-
|
30
|
-
* No changes.
|
31
|
-
|
32
|
-
|
33
|
-
## Rails 6.1.1 (January 07, 2021) ##
|
34
|
-
|
35
|
-
* No changes.
|
36
|
-
|
37
|
-
|
38
|
-
## Rails 6.1.0 (December 09, 2020) ##
|
39
|
-
|
40
|
-
* `ActionCable::Connection::Base` now allows intercepting unhandled exceptions
|
41
|
-
with `rescue_from` before they are logged, which is useful for error reporting
|
42
|
-
tools and other integrations.
|
43
|
-
|
44
|
-
*Justin Talbott*
|
45
|
-
|
46
|
-
* Add `ActionCable::Channel#stream_or_reject_for` to stream if record is present, otherwise reject the connection
|
47
|
-
|
48
|
-
*Atul Bhosale*
|
49
|
-
|
50
|
-
* Add `ActionCable::Channel#stop_stream_from` and `#stop_stream_for` to unsubscribe from a specific stream.
|
51
|
-
|
52
|
-
*Zhang Kang*
|
53
|
-
|
54
|
-
* Add PostgreSQL subscription connection identificator.
|
55
|
-
|
56
|
-
Now you can distinguish Action Cable PostgreSQL subscription connections among others.
|
57
|
-
Also, you can set custom `id` in `cable.yml` configuration.
|
58
|
-
|
59
|
-
```sql
|
60
|
-
SELECT application_name FROM pg_stat_activity;
|
61
|
-
/*
|
62
|
-
application_name
|
63
|
-
------------------------
|
64
|
-
psql
|
65
|
-
ActionCable-PID-42
|
66
|
-
(2 rows)
|
67
|
-
*/
|
68
|
-
```
|
69
|
-
|
70
|
-
*Sergey Ponomarev*
|
71
|
-
|
72
|
-
* Subscription confirmations and rejections are now logged at the `DEBUG` level instead of `INFO`.
|
73
|
-
|
74
|
-
*DHH*
|
75
|
-
|
76
|
-
|
77
|
-
Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/actioncable/CHANGELOG.md) for previous changes.
|