@@ -31,6 +31,32 @@ function init(display, container, module, ports, moduleToReplace) {
31 // defining state needed for an instance of the Elm RTS
31 // defining state needed for an instance of the Elm RTS
32 var inputs = [];
32 var inputs = [];
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().
40+ var timer = function() {
41+ var inducedDelay = 0;
43+ var now = function() {
44+ return Date.now() - inducedDelay;
47+ var addDelay = function(d) {
48+ if (typeof d !== "number") {
49+ throw "addDelay must take a number (preferably an int), not: " + d
56+ , addDelay : addDelay
34 var updateInProgress = false;
60 var updateInProgress = false;
35 function notify(id, v) {
61 function notify(id, v) {
36 if (updateInProgress) {
62 if (updateInProgress) {
@@ -40,7 +66,7 @@ function init(display, container, module, ports, moduleToReplace) {
40 'Definitely report this to <https://github.com/evancz/Elm/issues>\n');
66 'Definitely report this to <https://github.com/evancz/Elm/issues>\n');
42 updateInProgress = true;
68 updateInProgress = true;
43− var timestep = Date.now();
69+ var timestep = timer.now();
44 for (var i = inputs.length; i--; ) {
70 for (var i = inputs.length; i--; ) {
45 inputs[i].recv(timestep, id, v);
71 inputs[i].recv(timestep, id, v);
@@ -72,6 +98,7 @@ function init(display, container, module, ports, moduleToReplace) {
72 id:ElmRuntime.guid(),
98 id:ElmRuntime.guid(),
73 addListener:addListener,
99 addListener:addListener,
74 inputs:inputs,
100 inputs:inputs,
75 ports: { incoming:ports, outgoing:{}, uses:portUses }
102 ports: { incoming:ports, outgoing:{}, uses:portUses }