wires 0.1.3 → 0.1.4
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/lib/wires/channels.rb +7 -3
- data/lib/wires/hub.rb +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 660935c436c6c57687e2c3c8a506d9810e478789
|
4
|
+
data.tar.gz: e2cd88acddaade081ca3da917f885e40845d2282
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: addb4f0b4d550fa8e2d45d3124900a9a4a605c65ac05ebf10206bef54bffa23b6666ad4381ba675232e081fa75936e6e63639247f37f17b9c432852fa815477c
|
7
|
+
data.tar.gz: 670c122be77ebde3f81e87efb1d1317a526624cddb139c2e9ea9b988f5c1405b1c682b1f6c497c4e79a1b61fc9599b6fe0819a1c4eeaa8394fcaf2fdffb7fb6d
|
data/lib/wires/channels.rb
CHANGED
@@ -8,7 +8,11 @@ nil end
|
|
8
8
|
|
9
9
|
|
10
10
|
def fire(event, channel='*')
|
11
|
-
Channel(channel).fire(event)
|
11
|
+
Channel(channel).fire(event, blocking=false)
|
12
|
+
nil end
|
13
|
+
|
14
|
+
def fire_and_wait(event, channel='*')
|
15
|
+
Channel(channel).fire(event, blocking=true)
|
12
16
|
nil end
|
13
17
|
|
14
18
|
|
@@ -56,7 +60,7 @@ class Channel
|
|
56
60
|
nil end
|
57
61
|
|
58
62
|
# Fire an event on this channel
|
59
|
-
def fire(_event)
|
63
|
+
def fire(_event, blocking=false)
|
60
64
|
|
61
65
|
# Pull out args from optional array notation
|
62
66
|
_event = [_event] unless _event.is_a? Array
|
@@ -76,7 +80,7 @@ class Channel
|
|
76
80
|
for chan in relevant_channels()
|
77
81
|
for target in chan.target_list
|
78
82
|
for string in target[0] & event.class.codestrings
|
79
|
-
Hub << [string, event, *target[1..-1]]
|
83
|
+
Hub << [string, event, blocking, *target[1..-1]]
|
80
84
|
end end end
|
81
85
|
|
82
86
|
nil end
|
data/lib/wires/hub.rb
CHANGED
@@ -40,11 +40,12 @@ private
|
|
40
40
|
|
41
41
|
def self.process_item(x)
|
42
42
|
x, waiting_thread = x
|
43
|
-
string, event, proc = x
|
43
|
+
string, event, blocking, proc = x
|
44
44
|
Thread.new do
|
45
45
|
begin
|
46
|
-
waiting_thread.wakeup
|
46
|
+
waiting_thread.wakeup unless blocking
|
47
47
|
proc.call($event = event)
|
48
|
+
waiting_thread.wakeup if blocking
|
48
49
|
|
49
50
|
rescue Interrupt, SystemExit => e
|
50
51
|
@keepgoing = false
|