aboutsummaryrefslogtreecommitdiffstats
path: root/ethreact/README.md
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-21 21:46:26 +0800
committerobscuren <geffobscura@gmail.com>2014-08-21 21:46:26 +0800
commit0af0f0d890120e007ce42f072e1ee179a62115d3 (patch)
tree5ae9ecafbb729d1636fadfcfa49fd9100959560c /ethreact/README.md
parentd761af84c83ae8d9d723e6766abb7950ff59cdf3 (diff)
parentc173e9f4ab463cf3a44d35215bc29d846d6f6b02 (diff)
downloaddexon-0af0f0d890120e007ce42f072e1ee179a62115d3.tar.gz
dexon-0af0f0d890120e007ce42f072e1ee179a62115d3.tar.zst
dexon-0af0f0d890120e007ce42f072e1ee179a62115d3.zip
Merge branch 'release/0.6.3'
Diffstat (limited to 'ethreact/README.md')
-rw-r--r--ethreact/README.md28
1 files changed, 28 insertions, 0 deletions
diff --git a/ethreact/README.md b/ethreact/README.md
new file mode 100644
index 000000000..61af8a572
--- /dev/null
+++ b/ethreact/README.md
@@ -0,0 +1,28 @@
+## Reactor
+
+Reactor is the internal broadcast engine that allows components to be notified of ethereum stack events such as finding new blocks or change in state.
+Event notification is handled via subscription:
+
+ var blockChan = make(chan ethreact.Event, 10)
+ reactor.Subscribe("newBlock", blockChan)
+
+ethreact.Event broadcast on the channel are
+
+ type Event struct {
+ Resource interface{}
+ Name string
+ }
+
+Resource is polimorphic depending on the event type and should be typecast before use, e.g:
+
+ b := <-blockChan:
+ block := b.Resource.(*ethchain.Block)
+
+Events are guaranteed to be broadcast in order but the broadcast never blocks or leaks which means while the subscribing event channel is blocked (e.g., full if buffered) further messages will be skipped.
+
+The engine allows arbitrary events to be posted and subscribed to.
+
+ ethereum.Reactor().Post("newBlock", newBlock)
+
+
+ \ No newline at end of file