From 9c1b13fdfc573650d7e5f96de308483252025a12 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 30 Aug 2016 00:19:28 +0200 Subject: wip --- go/react/react.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'go') 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 } -- cgit v1.2.3