Implemented thread control for exported methods

This commit is contained in:
Nick Lockwood
2015-04-18 10:43:20 -07:00
parent 2b9aaac2ff
commit ead0f2e020
23 changed files with 384 additions and 403 deletions

View File

@@ -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");
}