grand_central 0.6.0 → 0.6.1
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/grand_central/store.rb +9 -2
- data/lib/grand_central/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bdf2cddcf8d8dd60b0ed935c59465212894b34c10bba4fa411668af4a10f1413
|
|
4
|
+
data.tar.gz: 6e962588d51ff887e484e29a2d92b58d6c3c591d69cd5812e884e28f712b6dc0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fb77a7aedb047d02040c990741f70a2f7e6ca717945b6c9ae210ea119ab4af791a8cb79cf623fd12db039546a5b5be5d1a2d1b5de9039900e62f73cd65a9a18e
|
|
7
|
+
data.tar.gz: 12fc78c06f8131c8be47a84a9094aabc9c389969589be45fa2b177d92804930e08e06dc2344c2b56b9573f1662143ba28daec48c3ab933257e7877067d6e1e75
|
data/lib/grand_central/store.rb
CHANGED
|
@@ -4,7 +4,8 @@ module GrandCentral
|
|
|
4
4
|
|
|
5
5
|
def initialize initial_state, &reducer
|
|
6
6
|
@state = initial_state
|
|
7
|
-
@reducer = reducer
|
|
7
|
+
@reducer = reducer || proc { |state| state }
|
|
8
|
+
@tagged_callbacks = {}
|
|
8
9
|
@dispatch_callbacks = []
|
|
9
10
|
end
|
|
10
11
|
|
|
@@ -15,7 +16,13 @@ module GrandCentral
|
|
|
15
16
|
action
|
|
16
17
|
end
|
|
17
18
|
|
|
18
|
-
def on_dispatch &block
|
|
19
|
+
def on_dispatch tag=nil, &block
|
|
20
|
+
if tag
|
|
21
|
+
current = @tagged_callbacks[tag]
|
|
22
|
+
@dispatch_callbacks.delete current if current
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
@tagged_callbacks[tag] = block
|
|
19
26
|
@dispatch_callbacks << block
|
|
20
27
|
self
|
|
21
28
|
end
|