From 8e3c2cf920dc187ff6dd891d5b31f2f55bddaf0c Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Sun, 4 Mar 2012 21:46:27 -0500 Subject: [PATCH] documenting the test function; need to show it to a few people --- js/world/test.rkt | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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.