Use match-event in box-and-client example
This commit is contained in:
parent
8b1d04ab05
commit
3c2995841e
|
@ -5,22 +5,20 @@
|
|||
(struct box-state (value) #:transparent)
|
||||
|
||||
(spawn (lambda (e current-value)
|
||||
(match e
|
||||
(match-event e
|
||||
[(message (set-box new-value))
|
||||
(log-info "box: taking on new-value ~v" new-value)
|
||||
(transition new-value (patch-seq (retract (box-state current-value))
|
||||
(assert (box-state new-value))))]
|
||||
[_ #f]))
|
||||
(assert (box-state new-value))))]))
|
||||
0
|
||||
(patch-seq (sub (set-box ?))
|
||||
(assert (box-state 0))))
|
||||
|
||||
(spawn (lambda (e s)
|
||||
(match e
|
||||
(match-event e
|
||||
[(patch added removed)
|
||||
(transition s (for-trie/list ([(box-state $v) added])
|
||||
(log-info "client: learned that box's value is now ~v" v)
|
||||
(message (set-box (+ v 1)))))]
|
||||
[_ #f]))
|
||||
(message (set-box (+ v 1)))))]))
|
||||
(void)
|
||||
(patch-seq (sub (box-state ?))))
|
||||
|
|
Loading…
Reference in New Issue