opal-actioncable 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb888a04e6ababbd2a42b5df4da76631f8e52442
4
- data.tar.gz: bed2a15fd759297c4e80ac65f7c2054fd3eca33b
3
+ metadata.gz: 2d4f3001a76feac9771f1a5efc10583bb13fd1ca
4
+ data.tar.gz: b770b1d29cd930346d21f334aa69d5d3a70b6ff3
5
5
  SHA512:
6
- metadata.gz: eeff47524c87c954267e3472beccfd37586f3c73b37296beddfdb8a904563211823542adaa15e41c0dae8547e9ef9f96909e14c4c32f1f431971502e88e45f5b
7
- data.tar.gz: ffd9aafe2c76b9eb8465e58e4a8297d6e42f94ae7cbe9800228dca5532efb8e7ac2afe8dea7757fb3c1d9646b692b8b22f22e2a32209c08f7bcbff43a6d03fe5
6
+ metadata.gz: eac55b8f222ca1fcf7fd38e92f2c50c05e12738bf2f9f0a4f6b7a9bcf72888f0ce61e8f60fd6579666db831347e240bd7b625dd15089a2355ba60eb86e6b35ec
7
+ data.tar.gz: 896a55ba6a1eb4eb4b91bf295269caf2f2c248cb6c7ff6f4e2599d7e90917d03884a08281e7a97cd6c76a4d55723d8c91d88436b8b91e22d243b2425c8edefaf
data/README.md CHANGED
@@ -43,6 +43,20 @@ Or install it yourself as:
43
43
  ChatChannel = TestChannel
44
44
  consumer.subscriptions.create ChatChannel, {channel: 'Chat', room: 'default'}
45
45
 
46
+ ### Skip client-side dispatching
47
+
48
+ If you send your messages in the format `{action: ..., data: ...}`
49
+
50
+ ActionCable.server.broadcast "channel", {action: 'action_name', data: {some: 'data'}}
51
+
52
+ And if `action` and `data` are the only keys in your hash, you can catch it on client side like this:
53
+
54
+ class TestChannel < ActionCable::Subscription
55
+ def action_name params
56
+ puts params # > {some: 'data'}
57
+ end
58
+ end
59
+
46
60
  ## Development
47
61
 
48
62
  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.
@@ -1,5 +1,5 @@
1
1
  module Opal
2
2
  module ActionCable
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
@@ -5,9 +5,9 @@ class ActionCable::Subscription
5
5
  @native = `new ActionCable.Subscription(#{consumer}, #{params.to_n})`
6
6
  %x{
7
7
  Opal.defn(self.$class(), 'perform', #{self}.$perform)
8
+ Opal.defn(self.$class(), 'received', #{self}.$_received)
8
9
  if (#{respond_to?(:disconnected)}) Opal.defn(self.$class(), 'disconnected', #{self}.$disconnected)
9
10
  if (#{respond_to?(:rejected)}) Opal.defn(self.$class(), 'rejected', #{self}.$rejected)
10
- if (#{respond_to?(:received)}) Opal.defn(self.$class(), 'received', #{self}.$_received)
11
11
  if (#{respond_to?(:connected)}) Opal.defn(self.$class(), 'connected', #{self}.$connected)
12
12
 
13
13
  Opal.defn(self.$class(), 'send', #{@native}.send)
@@ -34,7 +34,12 @@ class ActionCable::Subscription
34
34
 
35
35
  private
36
36
  def _received data
37
- received Hash.new data
37
+ data = Hash.new data
38
+ if (data.keys == ["action", "data"])
39
+ send(data["action"], data["data"])
40
+ else
41
+ received Hash.new data if respond_to?(:received)
42
+ end
38
43
  end
39
44
 
40
45
  end
@@ -19,5 +19,5 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency 'opal'
22
+ spec.add_dependency 'opal', '~> 0.9'
23
23
  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.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose Añasco
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-05-23 00:00:00.000000000 Z
12
+ date: 2016-06-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: opal
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '0'
20
+ version: '0.9'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ">="
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '0'
27
+ version: '0.9'
28
28
  description: Bring all the ActionCable goodness back to the ruby language
29
29
  email:
30
30
  - joseanasco1@gmail.com