mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-25 21:05:40 +08:00
Implemented thread control for exported methods
This commit is contained in:
@@ -187,21 +187,17 @@ RCT_EXPORT_METHOD(createTimer:(NSNumber *)callbackID
|
||||
interval:jsDuration
|
||||
targetTime:targetTime
|
||||
repeats:repeats];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
_timers[callbackID] = timer;
|
||||
[self startTimers];
|
||||
});
|
||||
_timers[callbackID] = timer;
|
||||
[self startTimers];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(deleteTimer:(NSNumber *)timerID)
|
||||
{
|
||||
if (timerID) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
_timers[timerID] = nil;
|
||||
if (_timers.count == 0) {
|
||||
[self stopTimers];
|
||||
}
|
||||
});
|
||||
_timers[timerID] = nil;
|
||||
if (_timers.count == 0) {
|
||||
[self stopTimers];
|
||||
}
|
||||
} else {
|
||||
RCTLogWarn(@"Called deleteTimer: with a nil timerID");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user