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)
|
(struct box-state (value) #:transparent)
|
||||||
|
|
||||||
(spawn (lambda (e current-value)
|
(spawn (lambda (e current-value)
|
||||||
(match e
|
(match-event e
|
||||||
[(message (set-box new-value))
|
[(message (set-box new-value))
|
||||||
(log-info "box: taking on new-value ~v" new-value)
|
(log-info "box: taking on new-value ~v" new-value)
|
||||||
(transition new-value (patch-seq (retract (box-state current-value))
|
(transition new-value (patch-seq (retract (box-state current-value))
|
||||||
(assert (box-state new-value))))]
|
(assert (box-state new-value))))]))
|
||||||
[_ #f]))
|
|
||||||
0
|
0
|
||||||
(patch-seq (sub (set-box ?))
|
(patch-seq (sub (set-box ?))
|
||||||
(assert (box-state 0))))
|
(assert (box-state 0))))
|
||||||
|
|
||||||
(spawn (lambda (e s)
|
(spawn (lambda (e s)
|
||||||
(match e
|
(match-event e
|
||||||
[(patch added removed)
|
[(patch added removed)
|
||||||
(transition s (for-trie/list ([(box-state $v) added])
|
(transition s (for-trie/list ([(box-state $v) added])
|
||||||
(log-info "client: learned that box's value is now ~v" v)
|
(log-info "client: learned that box's value is now ~v" v)
|
||||||
(message (set-box (+ v 1)))))]
|
(message (set-box (+ v 1)))))]))
|
||||||
[_ #f]))
|
|
||||||
(void)
|
(void)
|
||||||
(patch-seq (sub (box-state ?))))
|
(patch-seq (sub (box-state ?))))
|
||||||
|
|
Loading…
Reference in New Issue