diff --git a/js/world/test.rkt b/js/world/test.rkt index b097733..b08f0fa 100644 --- a/js/world/test.rkt +++ b/js/world/test.rkt @@ -14,16 +14,23 @@ ;; 2. A raw JavaScript function that can fire events +;; Let's attach the send-event function to a toplevel function on the window. (void ((js-function (js-eval "function(x) { window.sendTheTick = x; }")) send-event)) +;; js-function lifts JavaScript functions to regular function we can call. -(define (handle-event w v e f g) - (displayln e) - (displayln f) - (displayln g) +(define (tick w v) (add1 w)) + +;; Finally, let's use our big bang: (big-bang 0 - (on-event handle-event) + (on-event tick) ;; Note the on-event here (stop-when (lambda (w v) (> w 5)))) + + +;; Run this program. A big-bang should be in progress and show 0. +;; +;; Next, open up your developer window, and call window.sendTheTick(). +;; You should see the world respond.