@@ -27,33 +27,33 @@ Elm.worker = function(module, ports) {
2727 return init(ElmRuntime.Display.NONE, {}, module, ports || {});
2828};
2929
30−/* OFFSET
31− * Elm's time traveling debugger lets you interrupt the smooth flow of time
32− * by pausing and continuing program execution. To ensure the user sees a
33− * program that moves smoothly through the pause/continue time gap,
34− * we need to adjsut the value of Date.now().
35− */
36−Elm.timer = function() {
37− var inducedDelay = 0;
30+function init(display, container, module, ports, moduleToReplace) {
31+ // defining state needed for an instance of the Elm RTS
32+ var inputs = [];
3833
39− var now = function() {
40− return Date.now() - inducedDelay;
41− };
34+ /* OFFSET
35+ * Elm's time traveling debugger lets you interrupt the smooth flow of time
36+ * by pausing and continuing program execution. To ensure the user sees a
37+ * program that moves smoothly through the pause/continue time gap,
38+ * we need to adjsut the value of Date.now().
39+ */
40+ var timer = function() {
41+ var inducedDelay = 0;
4242
43− var addDelay = function(d) {
44− var delay = (d|0);
45− inducedDelay += delay;
46− return inducedDelay;
47− }
43+ var now = function() {
44+ return Date.now() - inducedDelay;
45+ };
4846
49− return { now : now
50− , addDelay : addDelay
51− }
52−}();
47+ var addDelay = function(d) {
48+ var delay = (d|0);
49+ inducedDelay += delay;
50+ return inducedDelay;
51+ }
5352
54−function init(display, container, module, ports, moduleToReplace) {
55− // defining state needed for an instance of the Elm RTS
56− var inputs = [];
53+ return { now : now
54+ , addDelay : addDelay
55+ }
56+ }();
5757
5858 var updateInProgress = false;
5959 function notify(id, v) {
@@ -64,7 +64,7 @@ function init(display, container, module, ports, moduleToReplace) {
6464 'Definitely report this to <https://github.com/evancz/Elm/issues>\n');
6565 }
6666 updateInProgress = true;
67− var timestep = Elm.timer.now();
67+ var timestep = timer.now();
6868 for (var i = inputs.length; i--; ) {
6969 inputs[i].recv(timestep, id, v);
7070 }
@@ -96,6 +96,7 @@ function init(display, container, module, ports, moduleToReplace) {
9696 id:ElmRuntime.guid(),
9797 addListener:addListener,
9898 inputs:inputs,
99+ timer:timer,
99100 ports: { incoming:ports, outgoing:{}, uses:portUses }
100101 };
101102