mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-01-31 17:18:45 +08:00
[react_native] JS files from D2087892: [react_native] Implement setInterval in JS
This commit is contained in:
@@ -43,7 +43,6 @@ var JSTimers = {
|
||||
var newID = JSTimersExecution.GUID++;
|
||||
var freeIndex = JSTimers._getFreeIndex();
|
||||
JSTimersExecution.timerIDs[freeIndex] = newID;
|
||||
JSTimersExecution.callbacks[freeIndex] = func;
|
||||
JSTimersExecution.callbacks[freeIndex] = function() {
|
||||
return func.apply(undefined, args);
|
||||
};
|
||||
@@ -60,12 +59,15 @@ var JSTimers = {
|
||||
var newID = JSTimersExecution.GUID++;
|
||||
var freeIndex = JSTimers._getFreeIndex();
|
||||
JSTimersExecution.timerIDs[freeIndex] = newID;
|
||||
JSTimersExecution.callbacks[freeIndex] = func;
|
||||
JSTimersExecution.callbacks[freeIndex] = function() {
|
||||
return func.apply(undefined, args);
|
||||
var startTime = Date.now();
|
||||
var ret = func.apply(undefined, args);
|
||||
var endTime = Date.now();
|
||||
RCTTiming.createTimer(newID, Math.max(0, duration - (endTime - startTime)), endTime, false);
|
||||
return ret;
|
||||
};
|
||||
JSTimersExecution.types[freeIndex] = JSTimersExecution.Type.setInterval;
|
||||
RCTTiming.createTimer(newID, duration, Date.now(), /** recurring */ true);
|
||||
RCTTiming.createTimer(newID, duration, Date.now(), /** recurring */ false);
|
||||
return newID;
|
||||
},
|
||||
|
||||
@@ -77,7 +79,6 @@ var JSTimers = {
|
||||
var newID = JSTimersExecution.GUID++;
|
||||
var freeIndex = JSTimers._getFreeIndex();
|
||||
JSTimersExecution.timerIDs[freeIndex] = newID;
|
||||
JSTimersExecution.callbacks[freeIndex] = func;
|
||||
JSTimersExecution.callbacks[freeIndex] = function() {
|
||||
return func.apply(undefined, args);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user