func (Materialize) Materialize() be.Reflex { sourceEndo, sourceExo := be.NewSynapse() seenEndo, seenExo := be.NewSynapse() go func() { h := &see{} h.seen = seenEndo.Focus(be.DontCognize) sourceEndo.Focus(h.CognizeSource) }() return be.Reflex{ "Source": sourceExo, "Materializen": seenExo, } }
func (WriteFile) Materialize() be.Reflex { nameEndo, nameExo := be.NewSynapse() contentEndo, contentExo := be.NewSynapse() go func() { h := writeFile{ named: make(chan struct{}), } nameEndo.Focus(h.CognizeName) contentEndo.Focus(h.CognizeContent) }() return be.Reflex{ "Name": nameExo, "Content": contentExo, } }
func (Clunk) Materialize() be.Reflex { _Endo, _Exo := be.NewSynapse() go func() { _Endo.Focus(clunk) }() return be.Reflex{"_": _Exo} }
func (Println) Materialize() be.Reflex { s, t := be.NewSynapse() go func() { s.Focus( func(v interface{}) { fmt.Printf("%v\n", v) }, ) }() return be.Reflex{DefaultValve: t} }
func (Scanln) Materialize() be.Reflex { s, t := be.NewSynapse() go func() { r := s.Focus(be.DontCognize) go func() { for { var em string fmt.Scanln(&em) r.ReCognize(em) } }() }() return be.Reflex{DefaultValve: t} }
func NewEyeCognizer(cog EyeCognizer, valve ...string) (be.Reflex, *Eye) { r := make(be.Reflex) eye := &Eye{ see: make(chan *change), show: make(map[string]*nerve), } for i, v_ := range valve { v := v_ x, y := be.NewSynapse() r[v] = x n := &nerve{ index: i, ch: make(chan *be.ReCognizer), } eye.show[v] = n if cog == nil { go func() { eye.connect( v, y.Focus( func(w interface{}) { eye.cognize(v, w) }, ), ) }() } else { go func() { eye.connect( v, y.Focus( func(w interface{}) { cog(eye, v, w) }, ), ) }() } } return r, eye }