on master help sign in
Properly define setTimeout for normal use
924ed91Evan Czaplicki
libraries/Native/Signal/Time.js+3−3
@@ -28,7 +28,7 @@ Elm.Native.Time.make = function(elm) {
28 var timeoutID = 0;
28 var timeoutID = 0;
29 function f(isOn, t) {
29 function f(isOn, t) {
30 if (isOn) {
30 if (isOn) {
31− timeoutID = elm.runDelayed(tick(!wasOn && isOn), msPerFrame);
31+ timeoutID = elm.setTimeout(tick(!wasOn && isOn), msPerFrame);
32 } else if (wasOn) {
32 } else if (wasOn) {
33 clearTimeout(timeoutID);
33 clearTimeout(timeoutID);
34 }
34 }
@@ -42,9 +42,9 @@ Elm.Native.Time.make = function(elm) {
42 var clock = NS.input(elm.timer.now());
42 var clock = NS.input(elm.timer.now());
43 function tellTime() {
43 function tellTime() {
44 elm.notify(clock.id, elm.timer.now());
44 elm.notify(clock.id, elm.timer.now());
45− elm.runDelayed(tellTime, t);
45+ elm.setTimeout(tellTime, t);
46 }
46 }
47− elm.runDelayed(tellTime, t);
47+ elm.setTimeout(tellTime, t);
48 return clock;
48 return clock;
49 }
49 }
50
50
runtime/Debugger.js+1−1
@@ -41,7 +41,7 @@ function debugModule(module, runtime) {
41 // so we can access all runtime properties too
41 // so we can access all runtime properties too
42 var wrappedRuntime = Object.create(runtime);
42 var wrappedRuntime = Object.create(runtime);
43 wrappedRuntime.notify = notifyWrapper;
43 wrappedRuntime.notify = notifyWrapper;
44− wrappedRuntime.runDelayed = setTimeoutWrapper;
44+ wrappedRuntime.setTimeout = setTimeoutWrapper;
45
45
46 // make a copy of the wrappedRuntime
46 // make a copy of the wrappedRuntime
47 var assignedPropTracker = Object.create(wrappedRuntime);
47 var assignedPropTracker = Object.create(wrappedRuntime);
runtime/Init.js+4
@@ -69,6 +69,9 @@ function init(display, container, module, ports, moduleToReplace) {
69 }
69 }
70 updateInProgress = false;
70 updateInProgress = false;
71 }
71 }
72+ function setTimeout(func, delay) {
73+ window.setTimeout(func, delay);
74+ }
72
75
73 var listeners = [];
76 var listeners = [];
74 function addListener(relevantInputs, domNode, eventName, func) {
77 function addListener(relevantInputs, domNode, eventName, func) {
@@ -90,6 +93,7 @@ function init(display, container, module, ports, moduleToReplace) {
90 // object. This permits many Elm programs to be embedded per document.
93 // object. This permits many Elm programs to be embedded per document.
91 var elm = {
94 var elm = {
92 notify:notify,
95 notify:notify,
96+ setTimeout:setTimeout,
93 node:container,
97 node:container,
94 display:display,
98 display:display,
95 id:ElmRuntime.guid(),
99 id:ElmRuntime.guid(),