summaryrefslogtreecommitdiff
path: root/go/react/react.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/react/react.go')
-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
}