motion-wiretap 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/motion-wiretap/all/signal.rb +1 -1
- data/lib/motion-wiretap/all/wiretap.rb +14 -13
- data/lib/motion-wiretap/version.rb +1 -1
- 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: c00742f3bdb9d4cd330e42f101a484650651a0ee
|
4
|
+
data.tar.gz: e2e14fb9ec9bf951cc51d2b3cae3722ebea63d31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f04ca6c2feb0c9f8c6d95ac969294d4c1b371907775451392c85e2c0fdecc63b1d755c0ea565027456e09226e4a4c1183a9d863f23202401df9ff72756f3891
|
7
|
+
data.tar.gz: 2cc1e685b0732dd594da91d3aeac89e25614bc78e7f4fbafaffca2255744c382cd69b019122e2873c4f44cface5e9ddb460a0e72a2dc3090694352cc845a1a81
|
@@ -9,12 +9,15 @@ module MotionWiretap
|
|
9
9
|
SINGLETON = Class.new.new
|
10
10
|
|
11
11
|
class Wiretap
|
12
|
+
# wiretaps have an intrinsic "current value"
|
13
|
+
attr :value
|
12
14
|
|
13
15
|
def initialize(&block)
|
14
16
|
@is_torn_down = false
|
15
17
|
@is_completed = false
|
16
18
|
@is_error = false
|
17
19
|
@queue = nil
|
20
|
+
@value = nil
|
18
21
|
|
19
22
|
@listener_handlers = []
|
20
23
|
@completion_handlers = []
|
@@ -70,6 +73,11 @@ module MotionWiretap
|
|
70
73
|
|
71
74
|
def trigger_changed(*values)
|
72
75
|
return if @is_torn_down || @is_completed || @is_error
|
76
|
+
if values.length == 1
|
77
|
+
@value = values.first
|
78
|
+
else
|
79
|
+
@value = values
|
80
|
+
end
|
73
81
|
|
74
82
|
@listener_handlers.each do |block_or_wiretap|
|
75
83
|
trigger_changed_on(block_or_wiretap, values)
|
@@ -215,11 +223,9 @@ module MotionWiretap
|
|
215
223
|
|
216
224
|
class WiretapKvo < WiretapTarget
|
217
225
|
attr :property
|
218
|
-
attr :value
|
219
226
|
|
220
227
|
def initialize(target, property, &block)
|
221
228
|
@property = property
|
222
|
-
@value = nil
|
223
229
|
@initial_is_set = false
|
224
230
|
@bound_to = []
|
225
231
|
super(target, &block)
|
@@ -239,25 +245,22 @@ module MotionWiretap
|
|
239
245
|
super
|
240
246
|
end
|
241
247
|
|
242
|
-
def trigger_changed(*values)
|
243
|
-
super(@value)
|
244
|
-
end
|
245
|
-
|
246
248
|
def bind_to(wiretap)
|
247
249
|
@bound_to << wiretap
|
248
250
|
wiretap.listen do |value|
|
249
251
|
@target.send("#{@property}=".to_sym, value)
|
250
252
|
end
|
251
|
-
wiretap.trigger_changed
|
253
|
+
wiretap.trigger_changed(wiretap.value)
|
252
254
|
|
253
255
|
return self
|
254
256
|
end
|
255
257
|
|
256
258
|
def observeValueForKeyPath(path, ofObject: target, change: change, context: context)
|
257
|
-
|
259
|
+
value = change[NSKeyValueChangeNewKey]
|
258
260
|
if @initial_is_set
|
259
|
-
trigger_changed(
|
261
|
+
trigger_changed(value)
|
260
262
|
else
|
263
|
+
@value = value
|
261
264
|
@initial_is_set = true
|
262
265
|
end
|
263
266
|
end
|
@@ -333,6 +336,7 @@ module MotionWiretap
|
|
333
336
|
def initialize(parent)
|
334
337
|
@parent = parent
|
335
338
|
@parent.listen(self)
|
339
|
+
@value = @parent.value
|
336
340
|
super()
|
337
341
|
end
|
338
342
|
|
@@ -353,7 +357,7 @@ module MotionWiretap
|
|
353
357
|
# passes the values through the filter before passing up to the parent
|
354
358
|
# implementation
|
355
359
|
def trigger_changed(*values)
|
356
|
-
if
|
360
|
+
if @filter.call(*values)
|
357
361
|
super(*values)
|
358
362
|
end
|
359
363
|
end
|
@@ -364,7 +368,6 @@ module MotionWiretap
|
|
364
368
|
|
365
369
|
def initialize(parent, combiner)
|
366
370
|
@combiner = combiner
|
367
|
-
|
368
371
|
super(parent)
|
369
372
|
end
|
370
373
|
|
@@ -381,7 +384,6 @@ module MotionWiretap
|
|
381
384
|
def initialize(parent, memo, reducer)
|
382
385
|
@reducer = reducer
|
383
386
|
@memo = memo
|
384
|
-
|
385
387
|
super(parent)
|
386
388
|
end
|
387
389
|
|
@@ -397,7 +399,6 @@ module MotionWiretap
|
|
397
399
|
|
398
400
|
def initialize(parent, mapper)
|
399
401
|
@mapper = mapper
|
400
|
-
|
401
402
|
super(parent)
|
402
403
|
end
|
403
404
|
|