opal-actioncable 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +34 -27
- data/lib/opal-actioncable/version.rb +1 -1
- data/opal/action_cable/connection.rb +3 -3
- data/test/minitest_helper.rb +4 -0
- data/test/test_opal/actioncable.rb +11 -0
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fc34998bd47586d7a3bffe08db36983123b4f60
|
4
|
+
data.tar.gz: f0e6423c4ca10c631f8b2904dc2d38b2a123e8e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 435dc1da70f7ecd532c8035660c0752669a0c11507abeb19e36bd97b96ef9344f457efc91ffc1e3694475064de806e8ff6cdb97f17f7ab1712ae5f21c0748b01
|
7
|
+
data.tar.gz: 7ccb132faf40ff8e40c544f71be5a22ecd3e34a6b39cade165aef9f661437eef67c4786d98740449ae894589b72ed3bab00067935a26f0f88c4409926c24b811
|
data/README.md
CHANGED
@@ -20,43 +20,50 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
```ruby
|
24
|
+
# assets/javascript/application.rb
|
25
|
+
require 'opal-actioncable'
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
class TestChannel < ActionCable::Subscription
|
28
|
+
def connected
|
29
|
+
perform 'send', {data: 23}
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
def disconnected
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
def received data
|
36
|
+
end
|
37
|
+
end
|
37
38
|
|
38
|
-
|
39
|
-
|
39
|
+
consumer = ActionCable.createConsumer
|
40
|
+
consumer.subscriptions.create TestChannel
|
40
41
|
|
41
|
-
|
42
|
+
# or
|
42
43
|
|
43
|
-
|
44
|
-
|
44
|
+
ChatChannel = TestChannel
|
45
|
+
consumer.subscriptions.create ChatChannel, {channel: 'Chat', room: 'default'}
|
46
|
+
```
|
45
47
|
|
46
48
|
### Skip client-side dispatching
|
47
|
-
|
49
|
+
|
48
50
|
If you send your messages in the format `{action: ..., data: ...}`
|
49
|
-
|
50
|
-
|
51
|
-
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
ActionCable.server.broadcast "channel", {action: 'action_name', data: {some: 'data'}}
|
54
|
+
```
|
55
|
+
|
52
56
|
And if `action` and `data` are the only keys in your hash, you can catch it on client side like this:
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
class TestChannel < ActionCable::Subscription
|
60
|
+
def action_name params
|
61
|
+
puts params # > {some: 'data'}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
```
|
65
|
+
|
66
|
+
|
60
67
|
## Development
|
61
68
|
|
62
69
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -4,7 +4,7 @@ class ActionCable::Connection
|
|
4
4
|
def initialize consumer
|
5
5
|
@native = `new ActionCable.Connection(#{consumer})`
|
6
6
|
@subscriptions = consumer.subscriptions
|
7
|
-
@monitor = ConnectionMonitor.new self
|
7
|
+
@monitor = ActionCable::ConnectionMonitor.new self
|
8
8
|
|
9
9
|
%x{
|
10
10
|
Opal.defn(self.$class(), 'send', function(){ return self.$delegate_native('send', arguments); });
|
@@ -19,7 +19,7 @@ class ActionCable::Connection
|
|
19
19
|
Opal.defn(self.$class(), 'getState', function(){ return self.$delegate_native('getState', arguments); });
|
20
20
|
Opal.defn(self.$class(), 'installEventHandlers', function(){ return self.$delegate_native('installEventHandlers', arguments); });
|
21
21
|
Opal.defn(self.$class(), 'uninstallEventHandlers', function(){ return self.$delegate_native('uninstallEventHandlers', arguments); });
|
22
|
-
|
22
|
+
}
|
23
23
|
end
|
24
24
|
|
25
25
|
def send data
|
@@ -32,4 +32,4 @@ class ActionCable::Connection
|
|
32
32
|
end
|
33
33
|
|
34
34
|
|
35
|
-
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-actioncable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jose Añasco
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-06-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: opal
|
@@ -49,6 +49,8 @@ files:
|
|
49
49
|
- opal/action_cable/subscription.rb
|
50
50
|
- opal/action_cable/subscriptions.rb
|
51
51
|
- opal/opal-actioncable.rb
|
52
|
+
- test/minitest_helper.rb
|
53
|
+
- test/test_opal/actioncable.rb
|
52
54
|
homepage: https://github.com/MichaelSp/opal-actioncable
|
53
55
|
licenses: []
|
54
56
|
metadata: {}
|
@@ -68,8 +70,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
70
|
version: '0'
|
69
71
|
requirements: []
|
70
72
|
rubyforge_project:
|
71
|
-
rubygems_version: 2.
|
73
|
+
rubygems_version: 2.6.8
|
72
74
|
signing_key:
|
73
75
|
specification_version: 4
|
74
76
|
summary: ActionCable adapter for Opal
|
75
|
-
test_files:
|
77
|
+
test_files:
|
78
|
+
- test/minitest_helper.rb
|
79
|
+
- test/test_opal/actioncable.rb
|