summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-08-30 00:19:28 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-08-30 00:19:28 +0200
commit9c1b13fdfc573650d7e5f96de308483252025a12 (patch)
treee5504a0f6b22bb49b1820efea161c1f52771daca
parent4fab4df4f284ab997f27f477d9ab7caa74d0738a (diff)
wip
-rw-r--r--go/react/react.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/go/react/react.go b/go/react/react.go
index d625f9b..99b40d7 100644
--- a/go/react/react.go
+++ b/go/react/react.go
@@ -5,6 +5,7 @@ const testVersion = 4
/* reactor */
type reactor struct {
+ cells []compuCell // XXX
}
func New() Reactor {
@@ -12,24 +13,23 @@ func New() Reactor {
}
func (r *reactor) CreateCompute1(c Cell, f func(int) int) ComputeCell {
- cc := &compuCell{
+ return &compuCell{
eval: func() int { return f(c.Value()) },
cb: make(map[CallbackHandle]func(int)),
}
- return cc
}
func (r *reactor) CreateCompute2(c1, c2 Cell, f func(int, int) int) ComputeCell {
- cc := &compuCell{
+ return &compuCell{
eval: func() int { return f(c1.Value(), c2.Value()) },
cb: make(map[CallbackHandle]func(int)),
}
- return cc
}
func (r *reactor) CreateInput(i int) InputCell {
return &inputCell{
- value: i,
+ value: i,
+ reactor: r, // XXX
}
}
@@ -37,10 +37,11 @@ func (r *reactor) CreateInput(i int) InputCell {
type inputCell struct {
value int
+ *reactor
}
func (c *inputCell) SetValue(i int) {
- // TODO call back
+ // TODO trigger call back
if c.value != i {
c.value = i
}