diff --git a/js/world.rkt b/js/world.rkt new file mode 100644 index 0000000..69199c4 --- /dev/null +++ b/js/world.rkt @@ -0,0 +1,3 @@ +#lang s-exp "../lang/base.rkt" +(require "world/main.rkt") +(provide (all-from-out "world/main.rkt")) \ No newline at end of file diff --git a/js/world/js-impl.js b/js/world/js-impl.js index 26689ab..ce51293 100644 --- a/js/world/js-impl.js +++ b/js/world/js-impl.js @@ -3,13 +3,17 @@ "use strict"; var WebWorld = - MACHINE.modules['whalesong/web-world.rkt'].privateExports; + MACHINE.modules['whalesong/web-world/impl.rkt'].privateExports; var EventSource = WebWorld.EventSource; var EventHandler = WebWorld.EventHandler; - var makeClosure = plt.runtime.makeClosure; + var makeClosure = plt.baselib.functions.makeClosure; + var makePrimitive = plt.baselib.functions.makePrimitive; var finalizeClosureCall = plt.runtime.finalizeClosureCall; + var checkProcedure = plt.baselib.check.checkProcedure; + + /** * Creates an event source coupled to a JavaScript function. Calling the function @@ -46,8 +50,19 @@ 'make-js-world-event', 0, function(M) { - finalizeClosureCall(M, "first value", "second value"); - + var eventSourceRecord = makeJsEventSource(); + eventSourceRecord.eventSource + var makeHandler = makePrimitive('make-js-world-event', + 1, + function(M) { + var onEvent = checkProcedure(M, 'js-world-event-handler', 0); + return new EventHandler('js-world-event', + eventSourceRecord.eventSource, + onEvent); + }); + finalizeClosureCall(M, + "first value", + eventSourceRecord.sender); }); diff --git a/js/world/main.rkt b/js/world/main.rkt index def389d..b2d0733 100644 --- a/js/world/main.rkt +++ b/js/world/main.rkt @@ -1,4 +1,4 @@ -#lang s-exp "../lang/js/js.rkt" +#lang s-exp "../../lang/js/js.rkt" (require "../../web-world.rkt") (declare-implementation #:racket "racket-impl.rkt" diff --git a/js/world/test.rkt b/js/world/test.rkt index 33101fc..bc87254 100644 --- a/js/world/test.rkt +++ b/js/world/test.rkt @@ -1,5 +1,6 @@ #lang planet dyoo/whalesong -(require (planet dyoo/whalesong/js/world)) +(require (planet dyoo/whalesong/js/world) + (planet dyoo/whalesong/js)) (define-values (on-event send-event) (make-js-world-event)) @@ -8,7 +9,6 @@ send-event) - on-event send-event diff --git a/web-world/js-impl.js b/web-world/js-impl.js index 684b27d..c4c25bc 100644 --- a/web-world/js-impl.js +++ b/web-world/js-impl.js @@ -2202,7 +2202,7 @@ // For private importers of the web-world library, like the FFI's js/world library. - Exports['EventSource'] = EventSource; - Exports['EventHandler'] = EventHandler; + EXPORTS['EventSource'] = EventSource; + EXPORTS['EventHandler'] = EventHandler; ////////////////////////////////////////////////////////////////////// }()); \ No newline at end of file